# Kerja Gaya Gesek

Muhammad Farhan1

Program Studi Sarjana Fisika, Institut Teknologi Bandung

Jalan Ganesha 10, Bandung 40132, Indonesia

1mfarhan1711@gmail.com, https://github.com/chromaaxion

Kerja yang dilakukan oleh gaya gesek merupakan bentuk kerja yang tidak diharapkan karena energi yang dikeluarkan, biasanya dalam bentuk panas atau bunyi yang dilepas ke lingkungan, tidak dapat dimanfaatkan lagi oleh sistem sehingga energi sistem berkurang.

## Gerak benda di atas lantai mendatar kasar
Sistem yang ditinjau adalah suatu benda yang bergerak di atas lantai mendatar kasar. Benda diberi kecepatan awal tertentu dan bergerak melambat sampai berhenti karena adanya gaya gesek kinetis antara benda dan lantai kasar.

## Parameter
Beberapa parameter yang digunakan adalah seperti pada tabel berikut ini.

Tabel 1. Simbol beserta satuan dan artinya.

Simbol | Satuan | Arti
:- | :- | :-
$t$ | s | waktu
$v_0$ | m/s | kecepatan awal
$x_0$ | m | posisi awal
$v$ | m/s | kecepatan saat $t$
$x$ | m | waktu saat $t$
$a$ | m/s2 | percepatan
$\mu_k$ | - | koefisien gesek kinetis
$f_k$ | N | gaya gesek kinetis
$m$ | kg | massa benda
$F$ | N | total gaya yang bekerja
$N$ | N | gaya normal
$w$ | N | gaya gravitasi

Simbol-simbol pada Tabel [1](#tab1) akan diberi nilai kemudian saat diimplementasikan dalam program.

## Persamaan
Persamaan-persamaan yang akan digunakan adalah seperti dicantumkan pada bagian ini.

### Kinematika
Hubungan antara antara kecepatan $v$, kecepatan awal $v_0$, percepatan $a$, dan waktu $t$ diberikan oleh

\begin{equation}\label{eqn:kinematics-v-a-t}\tag{1}
v = v_0 + at.
\end{equation}

Posisi benda $x$ bergantung pada posisi awal $x_0$, kecepatan awal $v_0$, percepatan $a$, dan waktu $t$ melalui hubungan

\begin{equation}\label{eqn:kinematics-x-v-a-t}\tag{2}
x = x_0 + v_0 t + \tfrac12 at^2.
\end{equation}

Selain kedua persamaan sebelumnya, terdapat pula persamaan berikut

\begin{equation}\label{eqn:kinematics-v-x-a}\tag{3}
v^2 = v_0^2 + 2a(x - x_0),
\end{equation}

yang menghubungkan kecepatan $v$ dengan kecepatan awal $v_0$, percepatan $a$, dan jarak yang ditempuh $x - x_0$.

### Dinamika
Hukum Newton I menyatakan bahwa benda yang semula diam akan tetap diam dan yang semula bergerak dengan kecepatan tetap akan tetap bergerak dengan kecepatan tetap bila tidak ada gaya yang bekerja pada benda atau jumlah gaya-gaya yang bekerja sama dengan nol

\begin{equation}\label{eqn:newtons-law-1}\tag{4}
\sum F = 0.
\end{equation}

Bila ada gaya yang bekerj pada benda bermassa $m$ atau jumlah gaya-gaya tidak nol

\begin{equation}\label{eqn:newtons-law-2}\tag{5}
\sum F = ma,
\end{equation}

maka keadaan gerak benda akan berubah melalui percepatan $a$, dengan $m > 0$ dan $a \ne 0$.

### Usaha
Usaha oleh suatu gaya $F$ dengan posisi awal $x_0$ dan posisi akhir $x_0$ dapat diperoleh melalui

\begin{equation}\label{eqn:work-1}\tag{6}
W = \int_{x_0}^x F dx
\end{equation}

atau dengan

\begin{equation}\label{eqn:work-2}\tag{7}
W = \Delta K
\end{equation}

dengan $K$ adalah energi kinetik. Persamaan ([7](#eqn7)) akan memberikan gaya oleh semua gaya. Dengan demikian bila $F$ adalah satu-satunya gaya yang bekerja pada benda, maka persamaan ini akan menjadi Persamaan ([6](#eqn6)).

## Sistem
Ilustrasi sistem perlu diberikan agar dapat terbayangan dan memudahkan penyelesaian masalah. Selain itu juga perlu disajikan diagram gaya-gaya yang bekerja pada benda.

### Ilustrasi
Sistem yang benda bermassa $m$ bergerak di atas lantai kasar dapat digambarkan
seperti berikut ini.

```python
%%html

<svg
   width="320"
   height="140"
   viewBox="0 0 320 140.00001"
   id="svg2"
   version="1.1"
   inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
   sodipodi:docname="mass-horizontal-rough-surface.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/">
  <defs
     id="defs4">
    <marker
       style="overflow:visible"
       id="TriangleOutM"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479" />
    </marker>
    <marker
       style="overflow:visible"
       id="marker11604"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11602" />
    </marker>
    <marker
       style="overflow:visible"
       id="Arrow2Mend"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11361" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-3"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-1" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-35"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-0" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-0"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-4" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-37"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-9" />
    </marker>
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1.5"
     inkscape:cx="173"
     inkscape:cy="97.333333"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:snap-bbox="false"
     inkscape:snap-global="false"
     units="px"
     showborder="true"
     inkscape:showpageshadow="true"
     borderlayer="false"
     inkscape:window-width="1366"
     inkscape:window-height="705"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1"
     inkscape:pagecheckerboard="0">
    <inkscape:grid
       type="xygrid"
       id="grid970" />
  </sodipodi:namedview>
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-732.36216)">
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="120.0725"
       y="759.6109"
       id="text2711-6-2-9"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2"
         x="120.0725"
         y="759.6109"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923">v</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668">0</tspan></tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM)"
       d="m 84.656156,757.55169 25.738704,1.3e-4"
       id="path11252" />
    <rect
       style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-opacity:1"
       id="rect1007"
       width="59"
       height="59"
       x="56.5"
       y="772.86218"
       rx="0"
       ry="0" />
    <path
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       d="m 20,832.86218 280,-2e-5"
       id="path1386" />
    <rect
       style="fill:#ffffff;fill-opacity:1;stroke:#c8c8c8;stroke-width:0.5;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:2, 2;stroke-dashoffset:0;stroke-opacity:1"
       id="rect1007-2"
       width="59"
       height="59"
       x="225.16667"
       y="772.86218"
       rx="0"
       ry="0" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#c8c8c8;fill-opacity:1;stroke:none"
       x="236.05922"
       y="759.6109"
       id="text2711-6-2-9-9"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-8"
         x="236.05922"
         y="759.6109"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, ';fill:#c8c8c8;fill-opacity:1"><tspan
   style="font-style:italic;fill:#c8c8c8;fill-opacity:1"
   id="tspan9923-8">v</tspan> = 0</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="149.18359"
       y="824.54877"
       id="text2711-6-2-9-96"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-6"
         x="149.18359"
         y="824.54877"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
   style="font-style:italic"
   id="tspan3028">μ<tspan
   style="font-size:65%;baseline-shift:sub"
   id="tspan3074">k</tspan></tspan> > 0</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="79.505844"
       y="806.37714"
       id="text2711-6-2-9-2"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-84"
         x="79.505844"
         y="806.37714"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">m</tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-37)"
       d="m 33.785239,770.82609 -1.3e-4,25.7387"
       id="path11252-5" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="29.173132"
       y="759.45776"
       id="text2711-6-2-9-8"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-2"
         x="29.173132"
         y="759.45776"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">g</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="79.368446"
       y="849.21539"
       id="text2711-6-2-9-23"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-3"
         x="79.368446"
         y="849.21539"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923-0">x</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668-9">0</tspan></tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="250.91145"
       y="849.21539"
       id="text2711-6-2-9-23-0"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-3-0"
         x="250.91145"
         y="849.21539"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923-0-3">x</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668-9-3" /></tspan></text>
  </g>
</svg>

<br/>

Gambar <a name='fig1'>1</a>. Sistem benda bermassa $m$ begerak di atas lantai
mendatar kasar dengan koefisien gesek kinetis $\mu_k$.
```

<svg
   width="320"
   height="140"
   viewBox="0 0 320 140.00001"
   id="svg2"
   version="1.1"
   inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
   sodipodi:docname="mass-horizontal-rough-surface.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/">
  <defs
     id="defs4">
    <marker
       style="overflow:visible"
       id="TriangleOutM"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479" />
    </marker>
    <marker
       style="overflow:visible"
       id="marker11604"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11602" />
    </marker>
    <marker
       style="overflow:visible"
       id="Arrow2Mend"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11361" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-3"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-1" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-35"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-0" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-0"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-4" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-37"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-9" />
    </marker>
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1.5"
     inkscape:cx="173"
     inkscape:cy="97.333333"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:snap-bbox="false"
     inkscape:snap-global="false"
     units="px"
     showborder="true"
     inkscape:showpageshadow="true"
     borderlayer="false"
     inkscape:window-width="1366"
     inkscape:window-height="705"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1"
     inkscape:pagecheckerboard="0">
    <inkscape:grid
       type="xygrid"
       id="grid970" />
  </sodipodi:namedview>
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-732.36216)">
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="120.0725"
       y="759.6109"
       id="text2711-6-2-9"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2"
         x="120.0725"
         y="759.6109"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923">v</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668">0</tspan></tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM)"
       d="m 84.656156,757.55169 25.738704,1.3e-4"
       id="path11252" />
    <rect
       style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-opacity:1"
       id="rect1007"
       width="59"
       height="59"
       x="56.5"
       y="772.86218"
       rx="0"
       ry="0" />
    <path
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       d="m 20,832.86218 280,-2e-5"
       id="path1386" />
    <rect
       style="fill:#ffffff;fill-opacity:1;stroke:#c8c8c8;stroke-width:0.5;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:2, 2;stroke-dashoffset:0;stroke-opacity:1"
       id="rect1007-2"
       width="59"
       height="59"
       x="225.16667"
       y="772.86218"
       rx="0"
       ry="0" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#c8c8c8;fill-opacity:1;stroke:none"
       x="236.05922"
       y="759.6109"
       id="text2711-6-2-9-9"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-8"
         x="236.05922"
         y="759.6109"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, ';fill:#c8c8c8;fill-opacity:1"><tspan
   style="font-style:italic;fill:#c8c8c8;fill-opacity:1"
   id="tspan9923-8">v</tspan> = 0</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="149.18359"
       y="824.54877"
       id="text2711-6-2-9-96"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-6"
         x="149.18359"
         y="824.54877"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
   style="font-style:italic"
   id="tspan3028">μ<tspan
   style="font-size:65%;baseline-shift:sub"
   id="tspan3074">k</tspan></tspan> > 0</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="79.505844"
       y="806.37714"
       id="text2711-6-2-9-2"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-84"
         x="79.505844"
         y="806.37714"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">m</tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-37)"
       d="m 33.785239,770.82609 -1.3e-4,25.7387"
       id="path11252-5" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="29.173132"
       y="759.45776"
       id="text2711-6-2-9-8"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-2"
         x="29.173132"
         y="759.45776"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">g</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="79.368446"
       y="849.21539"
       id="text2711-6-2-9-23"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-3"
         x="79.368446"
         y="849.21539"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923-0">x</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668-9">0</tspan></tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="250.91145"
       y="849.21539"
       id="text2711-6-2-9-23-0"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-3-0"
         x="250.91145"
         y="849.21539"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923-0-3">x</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668-9-3" /></tspan></text>
  </g>
</svg>

Gambar 1. Sistem benda bermassa $m$ begerak di atas lantai
mendatar kasar dengan koefisien gesek kinetis $\mu_k$.

Keadaan akhir benda, yaitu saat kecepatan $v = 0$ diberikan pada bagian kanan Gambar [1](#fig1) dengan warna abu-abu.

### Diagram gaya
Diagram gaya-gaya yang berja pada benda perlu dibuat berdasarkan informasi dari Gambar [1](#fig1) dan Tabel [1](#tab1), yang diberikan berikut ini.

```python
%%html

<svg
   width="320"
   height="200"
   viewBox="0 0 320 200.00001"
   id="svg2"
   version="1.1"
   inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
   sodipodi:docname="mass-horizontal-rough-surface-fbd.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/">
  <defs
     id="defs4">
    <marker
       style="overflow:visible"
       id="TriangleOutM"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479" />
    </marker>
    <marker
       style="overflow:visible"
       id="marker11604"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11602" />
    </marker>
    <marker
       style="overflow:visible"
       id="Arrow2Mend"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11361" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-3"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-1" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-35"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-0" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-0"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-4" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-37"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-9" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-9"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-8" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-9-3"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-8-3" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-37-5"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-9-9" />
    </marker>
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1.2079428"
     inkscape:cx="159.36185"
     inkscape:cy="35.597712"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:snap-bbox="false"
     inkscape:snap-global="false"
     units="px"
     showborder="true"
     inkscape:showpageshadow="true"
     borderlayer="false"
     inkscape:window-width="1366"
     inkscape:window-height="705"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1"
     inkscape:pagecheckerboard="0">
    <inkscape:grid
       type="xygrid"
       id="grid970" />
  </sodipodi:namedview>
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-732.36216)">
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="148.01953"
       y="766.72156"
       id="text2711-6-2-9-23"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-3"
         x="148.01953"
         y="766.72156"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">N</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="251.40584"
       y="806.94421"
       id="text2711-6-2-9"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2"
         x="251.40584"
         y="806.94421"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923">v</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668" /></tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM)"
       d="m 215.98949,804.88502 25.7387,1.3e-4"
       id="path11252" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="153.68098"
       y="915.71051"
       id="text2711-6-2-9-2"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-84"
         x="153.68098"
         y="915.71051"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">w</tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-37)"
       d="m 31.113403,791.97918 -1.3e-4,25.7387"
       id="path11252-5" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="26.501303"
       y="780.6109"
       id="text2711-6-2-9-8"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-2"
         x="26.501303"
         y="780.6109"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">g</tspan></text>
    <rect
       style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-opacity:1"
       id="rect1007"
       width="59"
       height="59"
       x="130.5"
       y="792.86218"
       rx="0"
       ry="0" />
    <g
       id="g1363"
       transform="translate(-6,20)">
      <path
         style="fill:none;stroke:#ff0000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-9)"
         d="m 161.00001,831.69534 -45.73871,1.3e-4"
         id="path11252-4" />
      <path
         style="fill:none;stroke:#0000ff;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-9-3)"
         d="m 160.79738,832.36215 -1.3e-4,-75.7387"
         id="path11252-4-6" />
    </g>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-37-5)"
       d="m 159.99967,822.02879 3.4e-4,75.73871"
       id="path11252-5-0" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="85.624084"
       y="854.51099"
       id="text2711-6-2-9-8-4"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-2-1"
         x="85.624084"
         y="854.51099"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">f<tspan
   style="font-size:65%;baseline-shift:sub"
   id="tspan2197">k</tspan></tspan></text>
  </g>
</svg>

<br>

Gambar <a name='fig2'>2</a>. Diagram gaya-gaya yang bekerja pada benda
bermassa $m$.
```

<svg
   width="320"
   height="200"
   viewBox="0 0 320 200.00001"
   id="svg2"
   version="1.1"
   inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
   sodipodi:docname="mass-horizontal-rough-surface-fbd.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/">
  <defs
     id="defs4">
    <marker
       style="overflow:visible"
       id="TriangleOutM"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479" />
    </marker>
    <marker
       style="overflow:visible"
       id="marker11604"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11602" />
    </marker>
    <marker
       style="overflow:visible"
       id="Arrow2Mend"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="Arrow2Mend"
       inkscape:isstock="true">
      <path
         transform="scale(-0.6)"
         d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
         id="path11361" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-3"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-1" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-35"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-0" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-0"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-4" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-37"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-9" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-9"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-8" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-9-3"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-8-3" />
    </marker>
    <marker
       style="overflow:visible"
       id="TriangleOutM-37-5"
       refX="0"
       refY="0"
       orient="auto"
       inkscape:stockid="TriangleOutM"
       inkscape:isstock="true">
      <path
         transform="scale(0.4)"
         style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
         d="M 5.77,0 -2.88,5 V -5 Z"
         id="path11479-9-9" />
    </marker>
  </defs>
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="1.2079428"
     inkscape:cx="159.36185"
     inkscape:cy="35.597712"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:snap-bbox="false"
     inkscape:snap-global="false"
     units="px"
     showborder="true"
     inkscape:showpageshadow="true"
     borderlayer="false"
     inkscape:window-width="1366"
     inkscape:window-height="705"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1"
     inkscape:pagecheckerboard="0">
    <inkscape:grid
       type="xygrid"
       id="grid970" />
  </sodipodi:namedview>
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(0,-732.36216)">
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="148.01953"
       y="766.72156"
       id="text2711-6-2-9-23"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-3"
         x="148.01953"
         y="766.72156"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">N</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="251.40584"
       y="806.94421"
       id="text2711-6-2-9"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2"
         x="251.40584"
         y="806.94421"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '"><tspan
           style="font-style:italic"
           id="tspan9923">v</tspan><tspan
           style="font-size:65%;baseline-shift:sub"
           id="tspan1668" /></tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM)"
       d="m 215.98949,804.88502 25.7387,1.3e-4"
       id="path11252" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="153.68098"
       y="915.71051"
       id="text2711-6-2-9-2"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-84"
         x="153.68098"
         y="915.71051"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">w</tspan></text>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-37)"
       d="m 31.113403,791.97918 -1.3e-4,25.7387"
       id="path11252-5" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="26.501303"
       y="780.6109"
       id="text2711-6-2-9-8"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-2"
         x="26.501303"
         y="780.6109"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">g</tspan></text>
    <rect
       style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-opacity:1"
       id="rect1007"
       width="59"
       height="59"
       x="130.5"
       y="792.86218"
       rx="0"
       ry="0" />
    <g
       id="g1363"
       transform="translate(-6,20)">
      <path
         style="fill:none;stroke:#ff0000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-9)"
         d="m 161.00001,831.69534 -45.73871,1.3e-4"
         id="path11252-4" />
      <path
         style="fill:none;stroke:#0000ff;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-9-3)"
         d="m 160.79738,832.36215 -1.3e-4,-75.7387"
         id="path11252-4-6" />
    </g>
    <path
       style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#TriangleOutM-37-5)"
       d="m 159.99967,822.02879 3.4e-4,75.73871"
       id="path11252-5-0" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:18.6667px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none"
       x="85.624084"
       y="854.51099"
       id="text2711-6-2-9-8-4"><tspan
         sodipodi:role="line"
         id="tspan2709-5-9-2-2-1"
         x="85.624084"
         y="854.51099"
         style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:18.6667px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, '">f<tspan
   style="font-size:65%;baseline-shift:sub"
   id="tspan2197">k</tspan></tspan></text>
  </g>
</svg>

Gambar 2. Diagram gaya-gaya yang bekerja pada benda
bermassa $m$.

Terlihat bahwa pada arah $y$ terdapat gaya normal $N$ dan gaya gravitasi $w$, sedangkan pada arah $x$ hanya terdapat gaya gesek kinetis $f_k$ yang melawan arah gerak benda. Arah gerak benda diberikan oleh arah kecepatan $v$.

## Metode numerik
Interasi suatu fungsi $f(x)$ berbentuk

\begin{equation}\label{eqn:integral-1}\tag{8}
A = \int_a^b f(x) dx
\end{equation}

dapat didekati dengan

\begin{equation}\label{eqn:integral-2}\tag{9}
A \approx \sum_{i = 0}^N f\left[ \tfrac12(x_i + x_{i+1}) \right] \Delta x
\end{equation}

yang dikenal sebagai metode persegi titik tengah, di mana

\begin{equation}\label{eqn:integral-3}\tag{10}
\Delta x = \frac{b - a}{N}
\end{equation}

dengan $N$ adalah jumlah partisi. Variabel $x_i$ pada Persamaan ([9](#eqn9)) diberikan oleh

\begin{equation}\label{eqn:integral-4}\tag{11}
x_i = a + i\Delta x
\end{equation}

dengan $i = 0, \dots, N$.

## Penyelesaian
Penerapan Persamaan ([1](#eqn1)), ([2](#eqn2)), ([3](#eqn3)), ([4](#eqn4)), dan ([5](#eqn5)) pada Gambar [2](#fig2) akan menghasilkan

\begin{equation}\label{eqn:friction}\tag{10}
f_k = \mu_k mg
\end{equation}

dan usahanya adalah

\begin{equation}\label{eqn:friction-work}\tag{11}
\begin{array}{rcl}
W & = & \displaystyle \int_{x_0}^x f_k dx \newline
& = & \displaystyle \int_{x_0}^x \mu_k m g dx \newline
& = & \displaystyle m g \int_{x_0}^x \mu_k dx
\end{array}
\end{equation}

dengan koefisien gesek statisnya dapat merupakan fungsi dari posisi $\mu_k = \mu_k(x)$.

```python
import numpy as np
import matplotlib.pyplot as plt
plt.ion()

# set integral lower and upper bounds
a = 0
b = 1

# generate x
x = [1, 2, 3, 4, 5]

# generate y from numerical integration
y = [1, 2, 3, 5, 6]

## plot results
fig, ax = plt.subplots()
ax.scatter(x, y)
ax.set_xlabel("$x - x^0$")
ax.set_ylabel("y")

from IPython import display
from IPython.core.display import HTML
HTML('''
<div>
Gambar <a name='fig3'>3</a>. Kurva antara usaha $W$ dan jarak tempuh $x - x_0$.
</div>
''')
```

## Diskusi
Berdasarkan Gambar [3](#fig3) dapat dijelaskan bahwa dengan $\mu_k = \mu_k(x)$ maka kurva $W(x)$ tidak lagi linier karena dipengaruhi oleh sejauh mana perhitungan kerja dilakukan.

## Kesimpulan
Perhitungan kerja dengan $\mu_k = \mu_k(x)$ telah dapat dilakukan.

## Referensi
1. J. A. C. Martins, J. T. Oden, F. M. F. Simões, "A study of static and kinetic friction", International Journal of Engineerting Science, vol 28, no 1, p 29-92, 1990, url <https://doi.org/10.1016/0020-7225(90)90014-A>.
1. Carl Rod Nave, "Friction", HyperPhysics, 2017, url <http://hyperphysics.phy-astr.gsu.edu/hbase/frict.html#fri> [20220419].
2. Wikipedia contributors, "Friction", Wikipedia, The Free Encyclopedia, 12 April 2022, 00:33 UTC, url <https://en.wikipedia.org/w/index.php?oldid=1082223658> [20220419].
3. Tia Ghose, Ailsa Harvey, "What is friction?", Live Science, 8 Feb 2022, url <https://www.livescience.com/37161-what-is-friction.html> [20220419].

```python

```


# FFM232, Klassisk fysik och vektorfält - Föreläsningsanteckningar

 **[Christian Forssén](http://fy.chalmers.se/subatom/tsp/), Institutionen för fysik, Chalmers, Göteborg, Sverige**

Date: **Oct 13, 2016**

# 11. Elektromagnetiska fält och Maxwells ekvationer

Vi startar med att betrakta *statiska* elektriska och magnetiska (elektrostatik och magnetostatik) för att sedan ta med *tidsberoendet* och se hur det innebär en koppling mellan de två fälten.

## Maxwells ekvationer (tidsoberoende fält)

### Elektrostatik

Statiska elektriska fält $\vec{E}(\vec{r})$ uppfyller

$$
\begin{equation}
  \vec{\nabla} \cdot \vec{E} = \frac{\rho}{\epsilon_0}
\end{equation}
$$

$$
\begin{equation}
  \vec{\nabla} \times \vec{E} = 0
\end{equation}
$$

där den första är Gauss lag och säger att elektriska fält kan ha elektriska
laddningar som källor.
* $\rho(\vec{r})$ = elektrisk laddningstäthet.

* $\epsilon_0$ = dielektricitetskonstant i vakuum

Den andra ekvationen säger att elektrostatiska fält är rotationsfria ($\vec{\nabla} \times \vec{E} = 0$) och därmed konservativa.
$$
\vec{E} = -\vec{\nabla} \phi,
$$
där $\phi$ är den elektrostatiska potentialen. Den uppfyller därmed Poissons ekvation
$$
\Delta \phi = - \frac{\rho}{\epsilon_0}
$$

### Magnetostatik

Statiska magnetiska fält $\vec{B}(\vec{r})$ uppfyller

$$
\begin{equation}
  \vec{\nabla} \cdot \vec{B} = 0
\end{equation}
$$

$$
\begin{equation}
  \vec{\nabla} \times \vec{B} = \mu_0 \vec{\jmath}
\end{equation}
$$

där den första säger att det inte finns några magnetiska laddningar och den andra är Amperes lag.
* $\vec{\jmath}(\vec{r})$ = elektrisk strömtäthet.

* $\mu_0$ = magnetisk permeabilitet i vakuum

Den första ekvationen säger att magnetostatiska fält är divergensfria ($\vec{\nabla} \cdot \vec{B} = 0$) (eller källfritt) och kan uttryckas med en vektorpotential
$$
\vec{B} = \vec{\nabla} \times \vec{A},
$$
där Gaugeinvarians innebär att vektorpotentialen inte är fullständigt
bestämd
$$
\vec{A}(\vec{r}) \mapsto \vec{A}(\vec{r}) + \vec{\nabla} \Lambda(\vec{r}).
$$
Detta gör det möjligt att välja Gaugeparameter så att $\vec{\nabla} \cdot \vec{A} = 0$ och vektorpotentialen uppfyller Poissons ekvation
$$
\Delta \vec{A} = -\mu_0 \vec{\jmath}.
$$

### SI enheter

$$
\begin{equation}
\mu_0 = 4 \pi \cdot 10^{-7} \; \mathrm{T}\mathrm{A}^{-1}\mathrm{m}^{-1} \nonumber
\end{equation}
$$

$$
\begin{equation}
\mu_0 \epsilon_0 = \frac{1}{c^2} \nonumber
\end{equation}
$$

$$
\begin{equation}
c = 299\,792\,458 \; \mathrm{m}\mathrm{s}^{-1} \nonumber
\end{equation}
$$

### Exempel: Bestämning av vektorpotentialen

--------------------------

Betrakta en elektrisk ledare parallell med $z$-axeln.  Genom ledaren flyter en ström $I$.  Då omges ledaren av ett magnetfält
$$
\vec{B} = \frac{\mu_0}{2\pi}\frac{I}{\rho}{\hat \varphi}.
$$
Bestäm vektorpotentialen $\vec{A}$ och finn den differentialekvation som beskriver detta fält.

[Comment 1: Notera att magnetfältet uppvisar en singularitet. Känns den igen? Det är fältet från en virveltråd.]

Notera att
$$
\vec{B} = \vec{\nabla} \times \vec{A} = \frac{1}{\rho}
\begin{vmatrix}
\hat{\rho} & \rho \hat{\varphi} & \hat{z} \\
\partial_\rho & \partial_\varphi & \partial_z \\
A_\rho & {\rho A_\varphi} & A_z
\end{vmatrix}
$$
Vi kan därför bestämma vektorpotentialen ur ekvationerna

7

<
<
<
!
!
M
A
T
H
_
B
L
O
C
K

$$
\begin{equation}
  \frac{\partial A_\rho}{\partial z} - \frac{\partial A_z}{\partial \rho} =
\frac{\mu_0}{2\pi}\frac{I}{\rho}
\label{phi} \tag{2}
\end{equation}
$$

och

$$
\begin{equation}
  \frac{1}{\rho}\left[\frac{\partial}{\partial \rho} \left(\rho A_\varphi\right)
- \frac{\partial A_\rho}{\partial \varphi}\right] = 0.
\label{z} \tag{3}
\end{equation}
$$

Vi skall finna en vektorpotential så att dessa ekvationer uppfylles. Vi provar med $A_\rho = A_\varphi=0$ och $A_z \neq 0$. Denna ansatz ger

$$
\begin{equation}
  \vec{A} = - \frac{\mu_0}{2\pi} I \log\frac{\rho}{\rho_0} { \hat z},
\end{equation}
$$

där $\rho_0$ är en godtycklig konstant.

Låt oss nu betrakta Amperes lag i det tidsoberoende fallet

$$
\begin{equation}
  \mu_0 \vec{\jmath} =  \vec{\nabla} \times \vec{B}.
\end{equation}
$$

Om vi nu ersätter $\vec{B}$ med $\vec{\nabla} \times \vec{A}$ så har vi

$$
\begin{equation}
  \vec{\nabla} \times \vec{\nabla} \times \vec{A} = \mu_0\vec{\jmath}.
\end{equation}
$$

För vänsterledet har vi räknereglen

$$
\begin{equation}
  \vec{\nabla} \times \vec{\nabla} \times \vec{A} =
\vec{\nabla}\left(\vec{\nabla}\cdot\vec{A}\right) -\vec{\nabla}^2\vec{A}
\end{equation}
$$

Den frihet, gauge, som vi har i att bestämma $\vec{A}$ gör det alltid möjligt att garantera att $\vec{\nabla} \cdot \vec{A} = 0$, så vi kan reducera ekvationen till

$$
\begin{equation}
  \vec{\nabla}^2 \vec{A} = -\mu_0 \vec{\jmath},
\end{equation}
$$

och vi har på så sätt kommit fram till en Poisson-ekvation för vektorpotentialen. Notera att gauge-valet $\vec{\nabla} \cdot \vec{A} = 0$ faktiskt är uppfyllt för den vektorpotential som vi konstruerade ovan.

----------------------------------------------------

## Maxwells ekvationer

[Comment 2: Maxwell satte 1864 upp fyra stycken ekvationer som gav en fullständig beskrivning av ett elektromagnetiskt fält.  Dock, som vi skall se, inskränkte sig hans eget bidrag till en term i en av ekvationerna.]

För *tidsberoende* fält finns det en koppling mellan elektriska och magnetiska fält
* Induktion (Faradays lag)

* Kontinuitet (konservering av elektrisk laddning)

[Comment 3: Vi har nu funnit att elektriska laddningar kan skapa elektriska fält  och att elektriska strömmar kan skapa magnetfält.]

[Comment 4: Vi vet dock att elektriska fält också kan skapas genom induktion.  En förändring av det magnetiska flödet, $\Phi$, genom en elektrisk ledare inducerar en spänning, $U$, i ledaren då det magnetiska flödet förändras.]

Faradays induktionslag

$$
\begin{equation}
  U = - \frac{\mbox{d}\Phi}{\mbox{d}t},
\end{equation}
$$

där $\Phi$ är ett magnetiskt flöde genom ytan $S$

$$
\begin{equation}
  \Phi = \int_S \vec{B} \cdot \mbox{d} \vec{S}.
\end{equation}
$$

och $U$ är den inducerade spänningen längs randen $\partial S$

$$
\begin{equation}
  U = \oint_{\partial S} \vec{E} \cdot \mbox{d}\vec{r}.
  \label{eq:indU} \tag{4}
\end{equation}
$$

Använd Stokes sats på ekv. [(4)](#eq:indU)
$$
  \int_S \left( \vec{\nabla} \times \vec{E}\right) \cdot \mbox{d}\vec{S} = -
\int_S \frac{\partial \vec{B}}{\partial t} \cdot \mbox{d}\vec{S}.
$$
Eftersom ytan är helt godtycklig måste likheten gälla för integranderna

$$
\begin{equation}
  \vec{\nabla} \times \vec{E} = - \frac{\partial \vec{B}}{\partial t}.
\end{equation}
$$

[Comment 5: Det elektriska fältet är inte längre konservativt vilket ju modifierar en av våra ekvationer.]

[Comment 6: Ekvationerna är dock inte kompletta i den här formen.  Den elektriska laddningen är en bevarad storhet i naturen.]

Låt oss nu betrakta sambandet mellan elektrisk strömtäthet och (rotationen av) ett magnetfält. Detta samband har konsekvenser för kontinuitetsekvationen för elektrisk laddning
$$
  \frac{\partial \rho}{\partial t} = - \vec{\nabla} \cdot \vec{\jmath}.
$$
från Amperes lag får vi nämligen att HL i kontinuitetsekvationen blir
$$
  \vec{\nabla} \cdot \vec{\jmath} = \frac{1}{\mu_0} \vec{\nabla} \cdot \left(\vec{\nabla} \times
\vec{B}\right) = 0,
$$
enligt räknereglerna för vektoroperatorerna. Detta skulle betyda att
$$
  \frac{\partial \rho}{\partial t} = 0,
$$
vilket är orimligt!
För det betyder att det inte går att flytta en elektrisk laddning.

Maxwells lösning var att lägga till en term (förskjutningsströmmen)

$$
\begin{equation}
  \vec{\nabla} \times \vec{B} = \mu_0 \vec{\jmath} + \mu_0 \epsilon_0 \frac{\partial \vec{E}}{\partial t}.
\end{equation}
$$

Vi får nu alltså att Maxwells ekvationer blir

$$
\begin{equation}
  \vec{\nabla} \cdot \vec{E} = \frac{\rho}{\epsilon_0},
\end{equation}
$$

$$
\begin{equation}
  \vec{\nabla} \times \vec{E} = - \frac{\partial B}{\partial t},
\end{equation}
$$

$$
\begin{equation}
  \vec{\nabla} \cdot \vec{B} = 0,
\end{equation}
$$

$$
\begin{equation}
  \vec{\nabla} \times \vec{B} = \mu_0 \vec{\jmath} + \mu_0 \epsilon_0
\frac{\partial E}{\partial t}.
\end{equation}
$$

* Ett allmänt fält $\vec{E}$ kan vi alltid dela upp i en del som är virvelfri, och en del som är källfri.

* För ett elektrisk fält gäller alltså att den virvelfria delen kan skrivas som $-\vec{\nabla} \phi$.  Enligt induktionsekvationen är

$$
\vec{\nabla} \times \vec{E} = - \frac{\partial \vec{B}}{\partial t} = -
\frac{\partial (\vec{\nabla} \times \vec{A})}{\partial t} = - \vec{\nabla} \times
\frac{\partial \vec{A}}{\partial t}.
$$
Alltså kan vi skriva den källfria delen av $\vec{E}$ som
$-\partial \vec{A} / \partial t$, så att vi totalt har

$$
\begin{equation}
  \vec{E} = - \vec{\nabla} \phi - \frac{\partial \vec{A}}{\partial t}.
\end{equation}
$$

### Exempel: Bestämning av elektriskt fält

--------------------------

En elektrisk laddning $Q$ är jämnt fördelad i en sfär med radien $a$. Den omges av ett tunt sfäriskt skal med radien 2a och laddningen $-Q$. Bestäm det elektriska fältet $\vec{E}(\vec{r})$ och potentialen $\phi(\vec{r})$ överallt.

*Lösning:* På grund av att laddningsfördelningen har sfärisk
symmetri, så blir $E_\varphi = E_\theta = 0$, och $E_r$ beror inte p\aa
~$\theta$ och $\varphi$.  Vi kan då beräkna $E_r$ med hjälp av Gauss
lag

$$
\begin{equation}
  \oint_S \vec{E} \cdot \mbox{d}\vec{S} = \frac{Q}{\epsilon_0},
\end{equation}
$$

där vi låter $S$ vara en sfär, och $Q$ är den laddning som innesluts
av $S$.

Om vi börjar med fallet att $S$ har en radie $r > 2a$, så ser vi
då att den totala inneslutna laddningen är $Q - Q = 0$.  Alltså har
vi att

$$
\begin{equation}
  \oint_S \vec{E} \cdot \mbox{d}\vec{S} = 0,
\end{equation}
$$

och av detta följer att att $E_r = 0$.

Om $S$ har en radie $r$ så att $a < r < 2a$, så är den laddningen,
som $S$ innesluter, $Q$.  Då ger oss Gauss lag att

$$
\begin{equation}
  \oint_S \vec{E} \cdot \mbox{d}\vec{S} = \frac{Q}{\epsilon_0}.
\end{equation}
$$

Integralen i vänsterledet har värdet

$$
\begin{equation}
  \oint_S \vec{E} \cdot \mbox{d}\vec{S} = 4\pi r^2 E_r,
\end{equation}
$$

och vi kan lösa ut

$$
\begin{equation}
  E_r = \frac{1}{4\pi \epsilon_0} \frac{Q}{r^2}.
\end{equation}
$$

Slutligen har vi fallet att sfärens radie $r < a$.  Eftersom laddningen $Q$
är jämt fördelad över volymen, så innebär det att $S$ innesluter
laddningen

$$
\begin{equation}
  Q \left(\frac{r}{a}\right)^3.
\end{equation}
$$

Gauss lag ger oss allts\aa

$$
\begin{equation}
  \oint_S \vec{E} \cdot \mbox{d}\vec{S} = \frac{Q}{\epsilon_0}
\left(\frac{r}{a}\right)^3,
\end{equation}
$$

vilket blir

$$
\begin{equation}
  4\pi r^2 E_r = \frac{Q}{\epsilon_0}\left(\frac{r}{a}\right)^3.
\end{equation}
$$

Vi kan nu lösa ut

$$
\begin{equation}
  E_r = \frac{1}{4\pi \epsilon_0} \frac{Qr}{a^3}.
\end{equation}
$$

Om vi nu sammanfattar våra resultat, så har vi för det elektriska
fältet

$$
\begin{equation}
  E_r = \left\{\begin{array}{lr}
\frac{1}{4\pi \epsilon_0} \frac{Qr}{a^3} & r < a\\
\frac{1}{4\pi \epsilon_0} \frac{Q}{r^2} & a < r < 2a\\
0 & r > 2a\\
\end{array}\right.
\end{equation}
$$

Vi skall nu utnyttja detta för att bestämma potentialen, för vilken det
gäller att $\vec{E} = - \vec{\nabla} \phi$.  I vårt fall kan vi uttrycka
potentialen som integralen

$$
\begin{equation}
  \phi\left(r\right) = \int_r^\infty E_r \mbox{d}r,
\end{equation}
$$

vilket sätter potentialen till 0 i oändligheten i enlighet med den vanliga
konventionen.  Vi börjar då med att bestämma potentialen för intervallet
$r > 2a$.  Eftersom $E_r = 0$ här så följer det att också potentialen
blir 0.

Potentialen skall överallt vara kontinuerlig, vilket inte behöver vara
sant för $E$-fältet.  Därför följer att när vi går till
intervallet $a \le r \le 2a$ så kan den övre integrationsgränsen
sättas till $2a$, eftersom potentialen är 0 utanför.

$$
\begin{equation}
  \phi\left(r\right) = \int_r^{2a} \frac{1}{4\pi \epsilon_0} \frac{Q}{r^2}
\mbox{d}r = \frac{Q}{4\pi\epsilon_0}\left[- \frac{1}{r}\right]_r^{2a} =
\frac{Q}{4\pi\epsilon_0} \left(\frac{1}{r}-\frac{1}{2a}\right).
\end{equation}
$$

Speciellt så lägger vi märke till att potentialen i punkten $r = a$
blir

$$
\begin{equation}
  \phi \left(a\right) = \frac{Q}{8\pi \epsilon_0 a}.
\end{equation}
$$

Det enklaste sättet att garantera att $\phi$ blir kontinuerlig vid $r = a$
är nu att skriva potentialen för $r\le a$ som

$$
\begin{equation}
  \phi \left(r\right) = \int_r^\infty E_r \mbox{d}r =
\frac{Q}{8\pi \epsilon_0 a} + \int_r^a \frac{Qr}{4\pi \epsilon_0 a^3}
\mbox{d}r = \frac{Q}{8\pi \epsilon_0 a} +
\left[\frac{Qr^2}{8\pi \epsilon_0 a^3}\right]_r^a = \nonumber
\end{equation}
$$

$$
\begin{equation}
\frac{Q}{8\pi \epsilon_0 a}
+  \frac{Q}{8\pi \epsilon_0 a} - \frac{Qr^2}{8\pi \epsilon_0 a^3} =
\frac{Q}{4\pi \epsilon_0 a} - \frac{Qr^2}{8\pi \epsilon_0 a^3} =
\frac{Q}{8\pi \epsilon_0} \frac{2a^2 -r^2}{a^3}.
\end{equation}
$$

Vi kan till slut sammanfatta potentialen som

$$
\begin{equation}
  \phi\left(r\right) = \left\{\begin{array}{lr}
\frac{Q}{8\pi \epsilon_0} \frac{2a^2 -r^2}{a^3} & r\le a\\
\frac{Q}{4\pi \epsilon_0} \left(\frac{1}{r} - \frac{1}{2a}\right) & a\le r \le
2a\\
0 & r \ge 2a\\
\end{array}
\right.
\end{equation}
$$

----------------------------------------------------

### Exempel: Bestämning av ett magnetfält

--------------------------

En oändligt lång rak ledare har ett cirkulärt tvärsnitt med radien
$a$ och leder en likström med strömstyrkan $I$.  Använd Amperes lag
för att härleda magnetfältet i och kring ledaren om materialet i den
antas homogent och isotropt.

*Lösning:* Vi vet att om den elektriska ledaren sammanfaller med  $z$-axeln så är magnetfältet riktat i $\varphi$-riktningen.  Vi kan då använda Amperes lag

$$
\begin{equation}
  \oint_{\partial S_\rho} \vec{B} \cdot \mbox{d}\vec{r} = \mu_0 I_\rho,
\end{equation}
$$

där vi låter $\partial S_\rho$ vara en cirkel kring $z$-axeln med radien $\rho$, och $I_\rho$ är
strömmen som passerar genom den yta som har $\partial S_\rho$ som rand.  Först
tittar vi på fallet att cirkelns radie $\rho > a$.  Strömmen
är då $I$, och Amperes lag ger oss

$$
\begin{equation}
  \oint_{\partial S_\rho} \vec{B} \cdot \mbox{d}\vec{r} = \mu_0 I.
\end{equation}
$$

Integralen blir då

$$
\begin{equation}
  \oint_{\partial S_\rho} \vec{B} \cdot \mbox{d}\vec{r} = 2\pi \rho B_\varphi.
\end{equation}
$$

Vi kan nu lösa ut

$$
\begin{equation}
  B_\varphi = \frac{\mu_0 I}{2\pi \rho}.
\end{equation}
$$

I fallet att cirkelns radie $\rho < a$ så antar vi att strömmen är
jämnt fördelad i tråden, vilket ger oss att den inneslutna strömmen
blir

$$
\begin{equation}
  I_\rho = I \left(\frac{\rho}{a}\right)^2.
\end{equation}
$$

Integralen blir nu

$$
\begin{equation}
  \oint_{\partial S_\rho} \vec{B} \cdot \mbox{d}\vec{r} = 2\pi \rho B_\varphi = \mu_0 I
\left(\frac{\rho}{a}\right)^2.
\end{equation}
$$

Vi kan då lösa

$$
\begin{equation}
  B_\varphi = \frac{\mu_0 I}{2\pi} \frac{\rho}{a^2}.
\end{equation}
$$

Sammanfattningsvis har vi alltså

$$
\begin{equation}
  B_\varphi = \left\{\begin{array}{lr}
\frac{\mu_0 I}{2\pi \rho} & \rho  a\\
\end{array}\right.
\end{equation}
$$

----------------------------------------------------

## Maxwells ekvationer i vakuum och den elektromagnetiska vågekvationen

[Comment 7: OBS! Resten av dessa anteckningar behandlar kap 11.3-11.7 som ej ingår i kursen. Anteckningarna är endast med för bättre koppling till motsvarande material i andra kurser. OBS!]

* En mycket viktig konsekvens av Maxwells ekvationer är att det existerar våglösningar.

I vakuum ($\rho=0$ och $\vec{\jmath} = 0$) blir Maxwells ekvationer

4
9

<
<
<
!
!
M
A
T
H
_
B
L
O
C
K

5
0

<
<
<
!
!
M
A
T
H
_
B
L
O
C
K

5
1

<
<
<
!
!
M
A
T
H
_
B
L
O
C
K

$$
\begin{equation}
  \vec{\nabla} \times \vec{B} = \epsilon \mu_0 \frac{\partial \vec{E}}{\partial t}
\label{amp_max} \tag{6}
\end{equation}
$$

Vi kan nu till exempel beräkna rotationen av induktionsekvationen Ekv. [(5)](#induction)

$$
\begin{equation}
  \vec{\nabla} \times \vec{\nabla} \times \vec{E} = \vec{\nabla} \left( \vec{\nabla} \cdot \vec{E}
\right) - \vec{\nabla}^2 \vec{E} = - \vec{\nabla} \times
\frac{\partial \vec{B}}{\partial t} =
- \frac{\partial (\vec{\nabla} \times \vec{B})}{\partial t}.
\end{equation}
$$

Vi kan nu utnyttja att $\vec{\nabla} \cdot \vec{E} =0$ och Ekv. [(6)](#amp_max)

$$
\begin{equation}
  - \vec{\nabla}^2 \vec{E} = - \frac{\partial}{\partial t} \epsilon_0 \mu_0
\frac{\partial \vec{E}}{\partial t} =
- \epsilon_0 \mu_0 \frac{\partial^2 \vec{E}}{\partial t^2}.
\end{equation}
$$

Eftersom $\epsilon_0 \mu_0 = 1/c^2$ kan vi skriva detta

$$
\begin{equation}
  \left( \vec{\nabla}^2 - \frac{1}{c^2} \frac{\partial^2}{\partial t^2} \right) \vec{E} = 0,
\label{vaag} \tag{7}
\end{equation}
$$

vilket är en *vågekvation*.

### Exempel: Vågekvationen i $D=1$

--------------------------

Betrakta fältet $\vec{E} = E(x,t)$ i en dimension och motsvarande vågekvation

$$
\begin{equation}
  \left( \frac{\partial^2}{\partial x^2} - \frac{1}{c^2} \frac{\partial^2}{\partial t^2} \right) E(x,t) = 0.
\end{equation}
$$

Ekvationen har då lösningar på formerna $E_+ = E_0 \sin(k x - \omega t)$ och $E_- = E_0 \sin(k x + \omega t)$, vilka beskriver vågor och motiverar varför Ekv. [(7)](#vaag) kallas för vågekvationen.

Med denna ansatz ($E_+$) ger vågekvationen
$$
-k^2 + \frac{\omega^2}{c^2} = 0 \quad \Rightarrow \quad \omega = c |k|,
$$
vilket kallas för en dispersionsrelation.

[Rita 8: funktionen $E(x,t)$ med en $x$-axel och en $t$-axel. Illustrera våglängd och periodtid.]

* Vid given tid $t$: samma fas då $x \mapsto x + \frac{2 \pi}{k}$.

* Dvs *våglängden* $\lambda$ relaterar till *vågtalet* $k$ enligt $\lambda = \frac{2\pi}{k}$.

* Vid givet $x$: samma fas då $t \mapsto t + \frac{2 \pi}{\omega}$.

* Våghastigheten finner vi genom att notera att $x-\frac{\omega}{k}t = \mathrm{konstant}$ beskriver punkter med samma fas. Detta ger

$$
\mbox{d}x - \frac{\omega}{k} \mbox{d}t = 0 \quad \Rightarrow \quad \frac{\mbox{d}x}{\mbox{d}t} = \frac{\omega}{k}
$$
Hastigheten är alltså $v = \omega / k = c$. Ljushastigheten!

-------------------------------------------------------

I rummet kan vi skriva lösningarna
$$
\vec{E} = \vec{E}_0 \exp\left( i (\vec{k} \cdot \vec{r} - \omega t ) \right) = \left\{ \mathrm{välj~} \vec{k} = k \hat{x} \right\} = \vec{E}_0 \exp\left( i (k x - \omega t) \right).
$$
Den fysikaliska lösningen är (antingen) real- eller imaginärdelen av ovanstående. Det betyder alltså att lösningen och tolkningen är analog med $D=1$-exemplet ovan.

### Elektriska och magnetiska vågor

En motsvarande vågekvation för magnetfältet kan också härledas. Man finner därför

$$
\begin{equation}
\vec{E}(\vec{r},t) = \vec{E}_0 \exp\left( i (\vec{k} \cdot \vec{r} - \omega t ) \right)  \nonumber
\end{equation}
$$

$$
\begin{equation}
\vec{B}(\vec{r},t) = \vec{B}_0 \exp\left( i (\vec{k} \cdot \vec{r} - \omega t ) \right)  \nonumber
\end{equation}
$$

Hur förhåller sig *polarisationsvektorn* $\vec{E}_0$ till $\vec{B}_0$ och till riktningen på $\vec{k}$?
* Sätt $\vec{k} = \hat{n} k = \hat{n} \frac{\omega}{c}$.

* Exponenten blir då $(\vec{k} \cdot \vec{r} - \omega t ) = \frac{\omega}{c}(\hat{n} \cdot \vec{r} - c t )$.

* ME1: $\vec{\nabla} \cdot \vec{E} = 0$, vilket ger $\hat{n} \cdot \vec{E}_0 = 0$.

Visa gärna detta med indexnotation

$$
\begin{equation}
\vec{\nabla} \cdot \vec{E} = \partial_j E_{0,j} \exp \left( i \frac{\omega}{c} (n_l r_l - ct) \right) = E_{0,j} \left( \partial_j \left[i \frac{\omega}{c} n_l r_l \right] \right) \exp \left( i \frac{\omega}{c} (n_m r_m - ct) \right) \nonumber
\end{equation}
$$

$$
\begin{equation}
= \left\{ \partial_j r_l = \delta_{jl} \right\} = i \frac{\omega}{c} E_{0,j} n_j \exp \left( i \frac{\omega}{c} (n_m r_m - ct) \right) \nonumber
\end{equation}
$$

$$
\begin{equation}
= i \frac{\omega}{c} \hat{n} \cdot \vec{E}_0 \exp \left( i \frac{\omega}{c} (\hat{n} \cdot \vec{r} - ct) \right) \nonumber
\end{equation}
$$

* Pss ME3 ger $\hat{n} \cdot \vec{B}_0 = 0$

* Fälten är alltså vinkelräta mot vågens rörelseriktning.

* ME2 säger att $i \frac{\omega}{c} (\hat{n} \times \vec{E}_0 - c \vec{B}_0) = 0$, dvs $\vec{B}_0 = \frac{1}{c} \hat{n} \times \vec{E_0}$.

* E- och B-fälten är alltså vinkelräta mot varandra.

* De två möjliga riktningarna på polarisationsvektorn $\vec{E}_0$ motsvarar de två möjliga polarisationerna hos elektromagnetisk strålning.

Den elektromagnetiska vågen består därför av svängande elektriska och magnetiska fält, vilka genererar varandra

$$
\begin{equation}
\vec{E}(\vec{r},t) = \vec{E}_0 \exp\left( i \frac{\omega}{c}(\hat{n} \cdot \vec{r} - c t ) \right), \quad \hat{n} \cdot \vec{E}_0 = 0
\end{equation}
$$

$$
\begin{equation}
\vec{B}(\vec{r},t) = \frac{1}{c} \hat{n} \times \vec{E}_0 \exp\left( i \frac{\omega}{c}(\hat{n} \cdot \vec{r} - c t ) \right)
\end{equation}
$$

## Vågekvationer för potentialerna

* Hur blir Maxwells ekvationer när fälten uttrycks i potentialerna $\phi$ och $\vec A$.

* De två homogena ekvationerna ($\ldots = 0$) är de som gör att fälten kan uttryckas i termer av potentialer.

Sätt in uttrycken

$$
\begin{equation}
\vec{E} = -\vec{\nabla} \phi - \frac{\partial \vec{A}}{\partial t} \nonumber
\end{equation}
$$

$$
\begin{equation}
\vec{B} = \vec{\nabla} \times \vec{A} \nonumber
\end{equation}
$$

i de inhomogena ekvationerna:

$$
\Big( \vec{\nabla} \cdot \vec{E} = \Big) \quad \vec{\nabla}\cdot(-\vec{\nabla}\phi-\frac{\partial \vec A}{\partial t}) = \frac{\rho}{\epsilon_0},
$$

$$
\Big( \vec{\nabla} \times \vec{B} - \epsilon \mu_0 \frac{\partial \vec{E}}{\partial t}
= \Big) \quad \vec{\nabla}\times(\vec{\nabla}\times\vec A) - \frac{1}{c^2} \frac{\partial}{\partial t} (-\vec{\nabla}\phi-\frac{\partial \vec A}{\partial t})=\mu_0\vec\jmath .
$$

* Ett gaugeval för vektorpotentialen förenklar ekvationerna avsevärt

* Välj gaugeparameter så att $\vec{\nabla}\cdot\vec A = - \frac{1}{c^2} \frac{\partial \phi}{\partial t}$.

Den första ekvationen blir
$$
\vec{\nabla} \cdot \left(-\vec{\nabla} \phi - \frac{\partial \vec{A}}{\partial t} \right) = -\Delta \phi - \frac{\partial}{\partial t} (\vec{\nabla} \cdot \vec{A}) = \left\{ \mathrm{Gaugeval} \right\} = \left( -\Delta + \frac{1}{c^2} \frac{\partial^2}{\partial t^2} \right) \phi \equiv - \square \phi,
$$
där d'Alembert-operatorn $\square \equiv \left( \Delta - \frac{1}{c^2} \frac{\partial^2}{\partial t^2} \right)$.

För den andra ekvationen utnyttjar vi att
$$
\vec{\nabla} \times \left( \vec{\nabla} \times \vec{A} \right) = \vec{\nabla} \left( \vec{\nabla} \cdot \vec{A} \right) - \Delta \vec{A} = \left\{ \mathrm{Gaugeval} \right\} = -\vec{\nabla} \left( \frac{1}{c^2} \frac{\partial \phi}{\partial t} \right) - \Delta \vec{A}.
$$
VL i den andra inhomogena ekvationen blir därför
$$
-\frac{1}{c^2} \frac{\partial (\vec{\nabla} \phi)}{\partial t} - \Delta \vec{A} + \frac{1}{c^2}
\frac{\partial \vec{\nabla} \phi}{\partial t} + \frac{1}{c^2} \frac{\partial^2 \vec{A}}{\partial  t^2} = -\square \vec{A}.
$$

* Vi får alltså inhomogena vågekvationer för potentialerna

$$
\square\phi=-\frac{\rho}{\epsilon_0},
$$

$$
\square\vec A=-\mu_0\vec\jmath ,
$$

* Man kan använda Greensfunktionen för vågekvationen för att skriva ned generella lösningar när laddningar och strömmar är givna.

* Greensfunktionen är lösningen till följande vågekvation

$$
\square G(\vec{r},t;\vec{r}{\;}',t') \equiv (\Delta - \frac{1}{c^2} \frac{\partial^2}{\partial t^2}) G(\vec{r},t;\vec{r}{\;}',t') = -\delta^3(\vec{r}-\vec{r}{\;}')\delta(t-t').
$$
För enkelhets skull kan vi ta $\vec{r}{\;}'=0$, $t'=0$.

Greensfunktionen är
$$
G_+(\vec{r},t;0,0) = \frac{1}{4\pi t} \delta(r-ct).
$$
* Detta är vad som brukar kallas en *retarderad* Greensfunktion.

* Termen kommer sig av att en källa bara påverkar fält vid efterföljande tider (ljuskonen $r=ct$).

[Comment 9: Ekvationen är symmetrisk under $t \to -t$, vilket innebär att det också finns en *avancerad* Greensfunktion $G_- \propto \delta(r+ct)$.]

[Comment 10: Det är värt att notera att det intuitivt "sunda" antagandet att Greensfunktionen endast har stöd på ljuskonen faktiskt är mer subtilt än det verkar. Det går under namnet Huygens pricip. Det visar sig vara sant i ett udda antal rumsdimensioner, men falskt i ett jämnt antal. I ett jämnt antal rumsdimensioner har Greensfunktionen stöd *inom* ljuskonen, inte endast *på* den.
I två dimensioner har man t.ex.
$$
G_+^{(2)}(\vec{r},t;0,0)=
\left\{
\begin{array}{ll}
\frac{\sigma(t)}{2\pi\sqrt{(ct)^2-r^2}}, & r<ct, \\
0 & \mathrm{annars.}
\end{array}
\right.
$$
Tänk på en sten som släpps i en vattenyta. En punkt på ytan påverkas inte bara just då vågfronten passerar, utan även vid alla senare tidpunkter. Tvådimensionell musik är kanske problematisk...]

Man måste förstås kunna bekräfta att man får rätt uttryck för en statisk laddningsfördelning. Om $\rho$ är oberoende av tiden ger Greensfunktionsmetoden

$$
\phi(\vec{r},t) =
\int_{\mathbb{R}^3}dV' \int_{-\infty}^\infty dt'
\frac{\rho(\vec{r}{\;}')}{\epsilon_0} G_+(\vec{r},t,\vec{r}{\;}',t')
$$

$$
= \int_{\mathbb{R}^3}dV' \int_{-\infty}^\infty dt'
\frac{\rho(\vec{r}{\;}')}{4\pi\epsilon_0(t-t')} \delta(|\vec{r}-\vec{r}{\;}'|-c(t-t'))
$$

$$
= \left\{ c(t-t') \equiv (x-x') \; \Rightarrow c \mathrm{~försvinner} \right\} =\int_{\mathbb{R}^3}dV'
\frac{\rho(\vec{r}{\;}')}{4\pi\epsilon_0|\vec{r}-\vec{r}{\;}'|},
$$

vilket är identiskt med vad man får med hjälp av Greensfunktionen för Poissons ekvation.


```python
import numpy as np
import ectopylasm as ep
import ipyvolume as ipv
```

```python
%load_ext line_profiler
```

# Mock data
Let's do only 100 points here.

```python
xyz = np.array((np.random.random(100), np.random.random(100), np.random.random(100)))
```

# Define shape

```python
thickness = 0.2

# plane
point = (0.5, 0.5, 0.5)
normal = (0, 1, 0)  # make it normalized to one
```

# Filter points

```python
import sympy as sy
import tqdm
```

```python
def filter_points_plane_slow(points_xyz, plane_point, plane_normal, plane_thickness, d=None):
    """
    Select the points that are within the thick plane.

    points_xyz: a vector of shape (3, N) representing N points in 3D space
    plane_point: a point in the plane
    plane_normal: the normal vector to the plane (x, y, z; any iterable)
    plane_thickness: the thickness of the plane (the distance between the two
                     composing planes)
    d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
                  specified, `plane_point` will be ignored
    """
    if d is not None:
        plane_point = ep.plane_point_from_d(plane_normal, d)
    point1, point2 = ep.thick_plane_points(plane_point, plane_normal, plane_thickness)
    plane1 = sy.geometry.Plane(sy.geometry.Point3D(point1), normal_vector=plane_normal)
    plane2 = sy.geometry.Plane(sy.geometry.Point3D(point2), normal_vector=plane_normal)

    p_filtered = []
    for p_i in tqdm.tqdm(points_xyz.T):
        sy_point_i = sy.geometry.Point3D(tuple(p_i))
        if plane1.distance(sy_point_i) <= plane_thickness and plane2.distance(sy_point_i) <= plane_thickness:
            p_filtered.append(p_i)
    return p_filtered
```

```python
plane_points = ep.filter_points_plane(xyz, point, normal, thickness)
```

```python
%lprun -f filter_points_plane_slow plane_points = filter_points_plane_slow(xyz, point, normal, thickness)
```

This gives the following output:

```
Timer unit: 1e-06 s

Total time: 28.1696 s
File: <ipython-input-13-5c9e992f6bd9>
Function: filter_points_plane_slow at line 1

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
     1                                           def filter_points_plane_slow(points_xyz, plane_point, plane_normal, plane_thickness, d=None):
     2                                               """
     3                                               Select the points that are within the thick plane.
     4
     5                                               points_xyz: a vector of shape (3, N) representing N points in 3D space
     6                                               plane_point: a point in the plane
     7                                               plane_normal: the normal vector to the plane (x, y, z; any iterable)
     8                                               plane_thickness: the thickness of the plane (the distance between the two
     9                                                                composing planes)
    10                                               d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
    11                                                             specified, `plane_point` will be ignored
    12                                               """
    13         1          2.0      2.0      0.0      if d is not None:
    14                                                   plane_point = ep.plane_point_from_d(plane_normal, d)
    15         1         16.0     16.0      0.0      point1, point2 = ep.thick_plane_points(plane_point, plane_normal, plane_thickness)
    16         1      17209.0  17209.0      0.1      plane1 = sy.geometry.Plane(sy.geometry.Point3D(point1), normal_vector=plane_normal)
    17         1       8052.0   8052.0      0.0      plane2 = sy.geometry.Plane(sy.geometry.Point3D(point2), normal_vector=plane_normal)
    18
    19         1          1.0      1.0      0.0      p_filtered = []
    20       101      91274.0    903.7      0.3      for p_i in tqdm.tqdm(points_xyz.T):
    21       100   26006837.0 260068.4     92.3          sy_point_i = sy.geometry.Point3D(tuple(p_i))
    22       100    2046189.0  20461.9      7.3          if plane1.distance(sy_point_i) <= plane_thickness and plane2.distance(sy_point_i) <= plane_thickness:
    23        17         38.0      2.2      0.0              p_filtered.append(p_i)
    24         1          2.0      2.0      0.0      return p_filtered
```

Really surprising result! I would have thought the distance calculation would be the slowest, but in fact the Point3D construction is **ridiculously** slow! So we definitely need to get rid of this whole `sympy.geometry` thing.

```python
def plane_d(point, normal):
    """
    Calculate d factor in plane equation ax + by + cz + d = 0
    """
    return -(point[0] * normal[0] + point[1] * normal[1] + point[2] * normal[2])
```

```python
def point_distance_to_plane(point, plane_point, plane_normal, d=None):
    """
    Get signed distance of point to plane.

    The sign of the resulting distance tells you whether the point is in
    the same or the opposite direction of the plane normal vector.

    point: an iterable of length 3 representing a point in 3D space
    plane_point: a point in the plane
    plane_normal: the normal vector to the plane (x, y, z; any iterable)
    d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
                  specified, `plane_point` will be ignored
    """
    if d is None:
        d = plane_d(plane_point, plane_normal)

    a, b, c = plane_normal
    # from http://mathworld.wolfram.com/Point-PlaneDistance.html
    return (a * point[0] + b * point[1] + c * point[2] + d) / np.sqrt(a**2 + b**2 + c**2)
```

```python
def filter_points_plane_numpy(points_xyz, plane_point, plane_normal, plane_thickness, d=None):
    """
    Select the points that are within the thick plane.

    points_xyz: a vector of shape (3, N) representing N points in 3D space
    plane_point: a point in the plane
    plane_normal: the normal vector to the plane (x, y, z; any iterable)
    plane_thickness: the thickness of the plane (the distance between the two
                     composing planes)
    d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
                  specified, `plane_point` will be ignored
    """
    if d is not None:
        plane_point = ep.plane_point_from_d(plane_normal, d)
    point1, point2 = ep.thick_plane_points(plane_point, plane_normal, plane_thickness)

    p_filtered = []
    for p_i in points_xyz.T:
        distance_1 = abs(point_distance_to_plane(p_i, point1, plane_normal))
        distance_2 = abs(point_distance_to_plane(p_i, point2, plane_normal))
        if distance_1 <= plane_thickness and distance_2 <= plane_thickness:
            p_filtered.append(p_i)
    return p_filtered
```

```python
%timeit filter_points_plane_numpy(xyz, point, normal, thickness)
```

```python
%lprun -f filter_points_plane_numpy plane_points = filter_points_plane_numpy(xyz, point, normal, thickness)
```

This runs significantly faster. Interestingly, in a first iteration I still had tqdm in on the for loop, and that was then the dominant factor with 70% of runtime! Removing it shifted dominance to the distance functions, as we would expect:

```
Timer unit: 1e-06 s

Total time: 0.001685 s
File: <ipython-input-68-14cb67a3434b>
Function: filter_points_plane_numpy at line 1

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
     1                                           def filter_points_plane_numpy(points_xyz, plane_point, plane_normal, plane_thickness, d=None):
     2                                               """
     3                                               Select the points that are within the thick plane.
     4
     5                                               points_xyz: a vector of shape (3, N) representing N points in 3D space
     6                                               plane_point: a point in the plane
     7                                               plane_normal: the normal vector to the plane (x, y, z; any iterable)
     8                                               plane_thickness: the thickness of the plane (the distance between the two
     9                                                                composing planes)
    10                                               d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
    11                                                             specified, `plane_point` will be ignored
    12                                               """
    13         1          1.0      1.0      0.1      if d is not None:
    14                                                   plane_point = ep.plane_point_from_d(plane_normal, d)
    15         1         11.0     11.0      0.7      point1, point2 = ep.thick_plane_points(plane_point, plane_normal, plane_thickness)
    16
    17         1          0.0      0.0      0.0      p_filtered = []
    18       101         96.0      1.0      5.7      for p_i in points_xyz.T:
    19       100        759.0      7.6     45.0          distance_1 = abs(point_distance_to_plane(p_i, point1, plane_normal))
    20       100        727.0      7.3     43.1          distance_2 = abs(point_distance_to_plane(p_i, point2, plane_normal))
    21       100         77.0      0.8      4.6          if distance_1 <= plane_thickness and distance_2 <= plane_thickness:
    22        17         14.0      0.8      0.8              p_filtered.append(p_i)
    23         1          0.0      0.0      0.0      return p_filtered

```

So this is an increase of a factor more than ~10000 in speed! Note that this is still with profiling on, and line_profiler seems to add an overhead of a factor ~4.

```python
28.1696 / 0.00203
```

```python
%lprun -f point_distance_to_plane plane_points = filter_points_plane_numpy(xyz, point, normal, thickness)
```

With this, we see that precalculating `d` can actually give an additional ~15% boost.

```
Timer unit: 1e-06 s

Total time: 0.004167 s
File: <ipython-input-34-3113593bd746>
Function: point_distance_to_plane at line 1

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
     1                                           def point_distance_to_plane(point, plane_point, plane_normal, d=None):
     2                                               """
     3                                               Get signed distance of point to plane.
     4
     5                                               The sign of the resulting distance tells you whether the point is in
     6                                               the same or the opposite direction of the plane normal vector.
     7
     8                                               point: an iterable of length 3 representing a point in 3D space
     9                                               plane_point: a point in the plane
    10                                               plane_normal: the normal vector to the plane (x, y, z; any iterable)
    11                                               d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
    12                                                             specified, `plane_point` will be ignored
    13                                               """
    14       200        227.0      1.1      5.4      if d is None:
    15       200        726.0      3.6     17.4          d = plane_d(plane_point, plane_normal)
    16
    17       200        168.0      0.8      4.0      a, b, c = plane_normal
    18                                               # from http://mathworld.wolfram.com/Point-PlaneDistance.html
    19       200       3046.0     15.2     73.1      return (a * point[0] + b * point[1] + c * point[2] + d) / np.sqrt(a**2 + b**2 + c**2)```

```python
# def point_distance_to_plane(point, plane_point, plane_normal, d=None):
#     """
#     Get signed distance of point to plane.

#     The sign of the resulting distance tells you whether the point is in
#     the same or the opposite direction of the plane normal vector.

#     point: an iterable of length 3 representing a point in 3D space
#     plane_point: a point in the plane
#     plane_normal: the normal vector to the plane (x, y, z; any iterable)
#     d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
#                   specified, `plane_point` will be ignored
#     """
#     if d is None:
#         d = plane_d(plane_point, plane_normal)

#     a, b, c = plane_normal
#     plane_normal = np.array(plane_normal)
#     # from http://mathworld.wolfram.com/Point-PlaneDistance.html
#     return (np.sum(plane_normal * np.array(point)) + d) / np.sqrt(np.sum(plane_normal * plane_normal))
```

```python
# %lprun -f point_distance_to_plane plane_points = filter_points_plane_numpy(xyz, point, normal, thickness)
```

That increases runtime, so let's not.

One last try, precalculating d:

```python
def filter_points_plane_numpy(points_xyz, plane_point, plane_normal, plane_thickness, d=None):
    """
    Select the points that are within the thick plane.

    points_xyz: a vector of shape (3, N) representing N points in 3D space
    plane_point: a point in the plane
    plane_normal: the normal vector to the plane (x, y, z; any iterable)
    plane_thickness: the thickness of the plane (the distance between the two
                     composing planes)
    d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
                  specified, `plane_point` will be ignored
    """
    if d is not None:
        plane_point = ep.plane_point_from_d(plane_normal, d)
    plane_point_1, plane_point_2 = ep.thick_plane_points(plane_point, plane_normal, plane_thickness)
    d1 = plane_d(plane_point_1, plane_normal)
    d2 = plane_d(plane_point_2, plane_normal)

    p_filtered = []
    for p_i in points_xyz.T:
        distance_1 = point_distance_to_plane(p_i, None, plane_normal, d=d1)
        distance_2 = point_distance_to_plane(p_i, None, plane_normal, d=d2)
        if abs(distance_1) <= plane_thickness and abs(distance_2) <= plane_thickness:
            p_filtered.append(p_i)
    return p_filtered
```

```python
%timeit filter_points_plane_numpy(xyz, point, normal, thickness)
```

```python
%lprun -f filter_points_plane_numpy plane_points = filter_points_plane_numpy(xyz, point, normal, thickness)
```

```python
872/746
```

Again a small gain. In the profiling runs there's too much noise to measure the exact gain, but the timeit run shows at least a factor 1.15 faster runs.

```
Timer unit: 1e-06 s

Total time: 0.001374 s
File: <ipython-input-72-00d6dddaec0d>
Function: filter_points_plane_numpy at line 1

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
     1                                           def filter_points_plane_numpy(points_xyz, plane_point, plane_normal, plane_thickness, d=None):
     2                                               """
     3                                               Select the points that are within the thick plane.
     4
     5                                               points_xyz: a vector of shape (3, N) representing N points in 3D space
     6                                               plane_point: a point in the plane
     7                                               plane_normal: the normal vector to the plane (x, y, z; any iterable)
     8                                               plane_thickness: the thickness of the plane (the distance between the two
     9                                                                composing planes)
    10                                               d [optional]: the constant in the plane equation ax + by + cz + d = 0; if
    11                                                             specified, `plane_point` will be ignored
    12                                               """
    13         1          2.0      2.0      0.1      if d is not None:
    14                                                   plane_point = ep.plane_point_from_d(plane_normal, d)
    15         1         12.0     12.0      0.9      plane_point_1, plane_point_2 = ep.thick_plane_points(plane_point, plane_normal, plane_thickness)
    16         1          3.0      3.0      0.2      d1 = plane_d(plane_point_1, plane_normal)
    17         1          1.0      1.0      0.1      d2 = plane_d(plane_point_2, plane_normal)
    18
    19         1          0.0      0.0      0.0      p_filtered = []
    20       101         92.0      0.9      6.7      for p_i in points_xyz.T:
    21       100        595.0      6.0     43.3          distance_1 = point_distance_to_plane(p_i, None, plane_normal, d=d1)
    22       100        566.0      5.7     41.2          distance_2 = point_distance_to_plane(p_i, None, plane_normal, d=d2)
    23       100         87.0      0.9      6.3          if abs(distance_1) <= plane_thickness and abs(distance_2) <= plane_thickness:
    24        17         16.0      0.9      1.2              p_filtered.append(p_i)
    25         1          0.0      0.0      0.0      return p_filtered
```

That'll do for now. So in total, we went from:

```python
%timeit filter_points_plane_slow(xyz, point, normal, thickness)
```

... ~7 seconds to ~700 microseconds, i.e. a speed-up factor of 10000. Decent.

# Test

Are the results the same though?

```python
p_slow = filter_points_plane_slow(xyz, point, normal, thickness)
p_numpy = filter_points_plane_numpy(xyz, point, normal, thickness)
```

```python
np.array(p_slow) == np.array(p_numpy)
```

Yessur!

```python

```


# Test bed for EM numerical algorithms

TODO: https://en.wikipedia.org/wiki/Finite-difference_time-domain_method

https://en.wikipedia.org/wiki/Computational_electromagnetics

```python
# libraries
import matplotlib.pyplot as plt
import numpy as np

import sympy as sp
from sympy.abc import * # skip declaring symbols, eats up namespace though
#!pip install magpylib
import magpylib as em

import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.wrappers.scikit_learn import KerasClassifier
from keras.utils import np_utils
```

```python
# data paths, it may not load these
train_path = 'swarg_training_data.npz'
test_path = 'swarg_eval_data.npz'
```

```python
# sympy test
x = symbols('x')
N = sp.integrate(sp.exp(-x**2),x)
N
```

$\displaystyle \frac{\sqrt{\pi} \operatorname{erf}{\left(x \right)}}{2}$

```python
# numpy test
x = np.arange(0, np.pi,.01)
y1 = np.sin(x)
y2 = np.sin(np.pi*x)

# matplotlib test
plt.plot(x,y2)
```

```python
# "This debug account can edit" - debug1500
```

## mark downn lang represent $\Omega$

```python
# test neural network stuff
def basemodel():
  model = Sequential()

  #Adding 20% dropout
  model.add(Dropout(0.20))

  #Add 1 layer with output 200 and relu function
  model.add(Dense(200,activation='relu'))

  #Adding 20% dropout here
  model.add(Dropout(0.20))

  #Add 1 layer with output 1 and sigmoid function
  model.add(Dense(1,activation='sigmoid'))

  return model

model = basemodel()
```

```python
import itertools

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

def data_gen():
    for cnt in itertools.count():
        t = cnt / 10
        yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)

def init():
    ax.set_ylim(-1.1, 1.1)
    ax.set_xlim(0, 10)
    del xdata[:]
    del ydata[:]
    line.set_data(xdata, ydata)
    return line,

fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2)
ax.grid()
xdata, ydata = [], []

def run(data):
    # update the data
    t, y = data
    xdata.append(t)
    ydata.append(y)
    xmin, xmax = ax.get_xlim()

    if t >= xmax:
        ax.set_xlim(xmin, 2*xmax)
        ax.figure.canvas.draw()
    line.set_data(xdata, ydata)

    return line

ani = animation.FuncAnimation(fig, run, data_gen, interval=10, init_func=init)
plt.show()
```

```python

```