{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "## BVPs, BCs, nonlinear, nonuniform grids\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Boundary conditions\n",
    "* Dirichlet conditions are straightforward\n",
    "    * Unknowns are interior points. Points near the boundaries are written in terms of the boundaries.\n",
    "* Neumann and Robin conditions:\n",
    "    * $y^{\\prime} = \\alpha$ is given at the boundary (or $y^{\\prime} + \\beta y = \\alpha$ for Robin).\n",
    "    * Interior cells need $y$ on the boundary, not $y^{\\prime}$.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "#### Two Approaches\n",
    "**Approach 1. Ghost Cell Method** Include the boundary point in the list of unknowns (like interior points).\n",
    "* Discretize the boundary point exactly as if it was an interior point.\n",
    "* For central differences, this will reference one point past the boundary.\n",
    "    ```        \n",
    "                \\\\|\n",
    "                \\\\|\n",
    "                \\\\|\n",
    "         *        *         *          *\n",
    "        i-1     \\\\|i       i+1       \n",
    "        -1      \\\\|0        1          2\n",
    "                \\\\|\n",
    "                \\\\|\n",
    "    ```\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "* Use the BC $y^{\\prime}=\\alpha$ as an equation for the new unknown $y_{-1}$.\n",
    "    $$y_0^{\\prime} = \\alpha \\rightarrow \\frac{y_1-y_{-1}}{2\\Delta x} = \\alpha \\rightarrow$$\n",
    "    <font color='blue'>\n",
    "    $$y_{-1}=y_{1} - 2\\Delta x\\alpha.$$\n",
    "    </font>\n",
    "* Substitute this equation in for $y_{i-1} = y_{-1}$ appearing in the finite difference equation (FDE) at point $i=0$. The first two equations below are the FDE at $i=0$. The last equation has the substitution for $y_{-1}$:\n",
    "    $$l_iy_{i-1} + a_iy_i + u_{i}y_{i+1} = F_i$$\n",
    "    $$\\mbox{or,}$$\n",
    "    $$l_0y_{-1}  + a_0y_0 + u_0y_{1} = F_0, $$\n",
    "    $$\\rightarrow a_0y_0 + (l_0+u_0)y_1 = F_0 + 2\\Delta x\\alpha l_0. $$\n",
    "* That is, the unknown $y_{-1}$ is in terms of $y_1$, so when we substitute it into the FDE at $i=0$, the coefficient of $y_1$ and the RHS are modified in the $i=0$ equation. \n",
    "* This is called the **Ghost Cell Method** since a false or *ghost* point arises, which is then handled with the boundary condition equation.\n",
    "    \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "\n",
    "* **Advantages**\n",
    "    * Solves directly for the unknown boundary value.\n",
    "    * Uses a uniform stencil (central difference everywhere, even at the boundaries.\n",
    "\n",
    "* **Disadvantage**\n",
    "    * Higher order $y^{\\prime\\prime\\prime}$ or higher order FDA can lead to multiple outside points, which can be awkward.\n",
    "    * Remedy this using one-sided differences."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "**Method 2** Don't include the boundary point in the list of unkowns. \n",
    "\n",
    "    ```        \n",
    "    \\\\|\n",
    "    \\\\|\n",
    "    \\\\|\n",
    "      *         *          *        *  \n",
    "    \\\\|i-1      i         i+1\n",
    "    \\\\|-1       0          1        2  \n",
    "    \\\\|\n",
    "    ```\n",
    "* The first unknown point is $i=0$.\n",
    "* The FDE at this point is in terms of point $i-1=-1$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "* Use the Boundary condition at $i-1$ with a one-sided difference to get another equation to write $y_{-1}$ in terms of the interior points we are solving for ($y_0$, $y_{1}$, etc.)\n",
    "* At the left side for the $i=0$ FDE (which has a $y_{-1}$ term):\n",
    "    * Write a one sided difference for $y^{\\prime}_{-1}$.\n",
    "    $$y^{\\prime}_{-1} = \\alpha = \\frac{-\\frac{3}{2}y_{-1} + 2y_0 - \\frac{1}{2}y_1}{\\Delta x}.$$\n",
    "    * Solve for $y_{-1}$:\n",
    "        <font color='blue'>\n",
    "        $$ y_{-1} = \\frac{\\alpha\\Delta x - 2y_0 + \\frac{1}{2}y_{1}}{-3/2}.$$\n",
    "        </font>\n",
    "    * The FDE at point $i=0$ is \n",
    "        $$l_0y_{-1} + a_0y_0 + u_0y_1 = F_0.$$\n",
    "    * Insert the above BC equation for $y_{-1}$ (blue) into this FDE to get the final FDE at the $i=0$ point.\n",
    "        $$ (a_0 + \\frac{4}{3}l_0)y_0 + (u_0 - \\frac{1}{3}l_0)y_1 = F_0 + \\frac{2}{3}\\alpha l_0\\Delta x.$$\n",
    "* A similar procedure is done at the right side of the domain.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "* **Advantage**\n",
    "    * Extends easily to higher order\n",
    "    * On the homework, if we exclude the BC point, then we don't have to divide by $r=0$ at the cylindrical centerline.\n",
    "* **Disadvantage**\n",
    "    * Two different stencils are needed. One for the fully interior points $i=1,\\,2,\\ldots$, and one for the point $i=0$ next to the boundary. (Similarly for the right side of the domain.)\n",
    "    * The boundary point remains unknown.\n",
    "        * Once the solution to the interior points $i=0,\\,1,\\ldots$ is found, we can find $y_{-1}$, (the boundary point), using the above blue equation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Nonlinear relaxation methods\n",
    "* The usual approach is to **iterate**\n",
    "    * Use a linearized form of the equation.\n",
    "    * Guess a solution.\n",
    "    * Iterate to improve it.\n",
    "* Apply the FDA to $y^{\\prime\\prime}$, $y^{\\prime}$ as before.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "\n",
    "* But consier a term like $y^\\prime y$\n",
    "    - This results in nonlinear terms:\n",
    "    $$y^{\\prime}y \\rightarrow \\left(\\frac{y_{i+1}-y_{i-1}}{2\\Delta x}\\right)\\cdot y_i.$$\n",
    "* We can linearize these terms by splitting the product and *lagging* part of it. For example\n",
    "    $$y_i^2\\rightarrow y_i\\cdot y_i \\rightarrow y_i^{new}\\cdot y_i^{old},$$\n",
    "    where $y_i^{old}$ is the value from the previous iteration, which is known.\n",
    "* For $$y^{\\prime\\prime} + P(x,y)y^{\\prime} + Q(x,y)y = F(x),$$\n",
    "use $$y^{\\prime\\prime} + P(x,y^{old})y^{\\prime} + Q(x,y^{old})y = F(x),$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "\n",
    "* Example\n",
    "    $$\\nabla\\cdot\\vec{q} = F \\rightarrow -\\nabla\\cdot(k\\nabla T) = F.$$\n",
    "    $$-\\frac{d}{dx}\\left(k\\frac{dT}{dx}\\right) = F.$$\n",
    "    $$\\frac{dT}{dx}\\frac{dk}{dx} + k\\frac{d^2T}{dx^2} = -F.$$\n",
    "    * $k = k(T)$ so the above equation is nonlinear. So lag $T$ when evaluating $k$. Use $k(T^{old})$.\n",
    "    * This is now linear, but we have to iterate.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "**Question** What are other approaches that could (or should?) be used?\n",
    "- Newton's method?\n",
    "- What about a Taylor Series linearization instead of the linearization shown?\n",
    "    - Consider $yy$\n",
    "        - above linearization: $yy\\approx y_0y$\n",
    "        - Taylor series: $yy\\approx y_0^2 + 2y_0(y-y_0)$\n",
    "        - Plot these for some arbitrary $y_0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import Plots as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 2400 1600\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip500\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip500)\" d=\"\n",
       "M0 1600 L2400 1600 L2400 0 L0 0  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip501\">\n",
       "    <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip500)\" d=\"\n",
       "M295.054 1384.3 L2352.76 1384.3 L2352.76 47.2441 L295.054 47.2441  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip502\">\n",
       "    <rect x=\"295\" y=\"47\" width=\"2059\" height=\"1338\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  353.291,1384.3 353.291,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  838.598,1384.3 838.598,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1323.9,1384.3 1323.9,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1809.21,1384.3 1809.21,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  2294.52,1384.3 2294.52,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  295.054,1384.3 2352.76,1384.3 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  353.291,1384.3 353.291,1365.4 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  838.598,1384.3 838.598,1365.4 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1323.9,1384.3 1323.9,1365.4 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1809.21,1384.3 1809.21,1365.4 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  2294.52,1384.3 2294.52,1365.4 \n",
       "  \"/>\n",
       "<path clip-path=\"url(#clip500)\" d=\"M319.367 1421.08 Q313.951 1421.08 311.208 1426.43 Q308.499 1431.74 308.499 1442.43 Q308.499 1453.09 311.208 1458.44 Q313.951 1463.75 319.367 1463.75 Q324.819 1463.75 327.527 1458.44 Q330.27 1453.09 330.27 1442.43 Q330.27 1431.74 327.527 1426.43 Q324.819 1421.08 319.367 1421.08 M319.367 1415.52 Q328.083 1415.52 332.666 1422.43 Q337.284 1429.31 337.284 1442.43 Q337.284 1455.52 332.666 1462.43 Q328.083 1469.31 319.367 1469.31 Q310.652 1469.31 306.034 1462.43 Q301.451 1455.52 301.451 1442.43 Q301.451 1429.31 306.034 1422.43 Q310.652 1415.52 319.367 1415.52 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M349.61 1459.48 L356.937 1459.48 L356.937 1468.3 L349.61 1468.3 L349.61 1459.48 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M387.214 1421.08 Q381.798 1421.08 379.055 1426.43 Q376.346 1431.74 376.346 1442.43 Q376.346 1453.09 379.055 1458.44 Q381.798 1463.75 387.214 1463.75 Q392.666 1463.75 395.374 1458.44 Q398.117 1453.09 398.117 1442.43 Q398.117 1431.74 395.374 1426.43 Q392.666 1421.08 387.214 1421.08 M387.214 1415.52 Q395.929 1415.52 400.513 1422.43 Q405.131 1429.31 405.131 1442.43 Q405.131 1455.52 400.513 1462.43 Q395.929 1469.31 387.214 1469.31 Q378.499 1469.31 373.881 1462.43 Q369.298 1455.52 369.298 1442.43 Q369.298 1429.31 373.881 1422.43 Q378.499 1415.52 387.214 1415.52 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M796.202 1462.4 L820.681 1462.4 L820.681 1468.3 L787.765 1468.3 L787.765 1462.4 Q791.758 1458.27 798.633 1451.32 Q805.542 1444.34 807.313 1442.33 Q810.681 1438.54 812.001 1435.94 Q813.355 1433.3 813.355 1430.77 Q813.355 1426.63 810.438 1424.03 Q807.556 1421.43 802.904 1421.43 Q799.605 1421.43 795.924 1422.57 Q792.279 1423.72 788.112 1426.04 L788.112 1418.96 Q792.348 1417.26 796.029 1416.39 Q799.709 1415.52 802.765 1415.52 Q810.82 1415.52 815.612 1419.55 Q820.404 1423.58 820.404 1430.31 Q820.404 1433.51 819.188 1436.39 Q818.008 1439.24 814.848 1443.13 Q813.98 1444.13 809.327 1448.96 Q804.674 1453.75 796.202 1462.4 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M835.403 1459.48 L842.73 1459.48 L842.73 1468.3 L835.403 1468.3 L835.403 1459.48 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M858.077 1416.46 L885.611 1416.46 L885.611 1422.36 L864.5 1422.36 L864.5 1435.07 Q866.028 1434.55 867.556 1434.31 Q869.084 1434.03 870.612 1434.03 Q879.292 1434.03 884.362 1438.79 Q889.431 1443.54 889.431 1451.67 Q889.431 1460.04 884.223 1464.69 Q879.014 1469.31 869.535 1469.31 Q866.271 1469.31 862.869 1468.75 Q859.501 1468.2 855.889 1467.08 L855.889 1460.04 Q859.014 1461.74 862.348 1462.57 Q865.681 1463.4 869.396 1463.4 Q875.403 1463.4 878.91 1460.24 Q882.417 1457.08 882.417 1451.67 Q882.417 1446.25 878.91 1443.09 Q875.403 1439.93 869.396 1439.93 Q866.584 1439.93 863.771 1440.56 Q860.994 1441.18 858.077 1442.5 L858.077 1416.46 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M1274.65 1416.46 L1302.19 1416.46 L1302.19 1422.36 L1281.08 1422.36 L1281.08 1435.07 Q1282.6 1434.55 1284.13 1434.31 Q1285.66 1434.03 1287.19 1434.03 Q1295.87 1434.03 1300.94 1438.79 Q1306.01 1443.54 1306.01 1451.67 Q1306.01 1460.04 1300.8 1464.69 Q1295.59 1469.31 1286.11 1469.31 Q1282.85 1469.31 1279.44 1468.75 Q1276.08 1468.2 1272.46 1467.08 L1272.46 1460.04 Q1275.59 1461.74 1278.92 1462.57 Q1282.26 1463.4 1285.97 1463.4 Q1291.98 1463.4 1295.48 1460.24 Q1298.99 1457.08 1298.99 1451.67 Q1298.99 1446.25 1295.48 1443.09 Q1291.98 1439.93 1285.97 1439.93 Q1283.16 1439.93 1280.35 1440.56 Q1277.57 1441.18 1274.65 1442.5 L1274.65 1416.46 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M1319.83 1459.48 L1327.15 1459.48 L1327.15 1468.3 L1319.83 1468.3 L1319.83 1459.48 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M1357.43 1421.08 Q1352.01 1421.08 1349.27 1426.43 Q1346.56 1431.74 1346.56 1442.43 Q1346.56 1453.09 1349.27 1458.44 Q1352.01 1463.75 1357.43 1463.75 Q1362.88 1463.75 1365.59 1458.44 Q1368.33 1453.09 1368.33 1442.43 Q1368.33 1431.74 1365.59 1426.43 Q1362.88 1421.08 1357.43 1421.08 M1357.43 1415.52 Q1366.14 1415.52 1370.73 1422.43 Q1375.35 1429.31 1375.35 1442.43 Q1375.35 1455.52 1370.73 1462.43 Q1366.14 1469.31 1357.43 1469.31 Q1348.71 1469.31 1344.1 1462.43 Q1339.51 1455.52 1339.51 1442.43 Q1339.51 1429.31 1344.1 1422.43 Q1348.71 1415.52 1357.43 1415.52 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M1758.69 1416.46 L1792.02 1416.46 L1792.02 1419.45 L1773.21 1468.3 L1765.88 1468.3 L1783.59 1422.36 L1758.69 1422.36 L1758.69 1416.46 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M1805.71 1459.48 L1813.03 1459.48 L1813.03 1468.3 L1805.71 1468.3 L1805.71 1459.48 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M1828.38 1416.46 L1855.91 1416.46 L1855.91 1422.36 L1834.8 1422.36 L1834.8 1435.07 Q1836.33 1434.55 1837.86 1434.31 Q1839.39 1434.03 1840.91 1434.03 Q1849.59 1434.03 1854.66 1438.79 Q1859.73 1443.54 1859.73 1451.67 Q1859.73 1460.04 1854.52 1464.69 Q1849.32 1469.31 1839.84 1469.31 Q1836.57 1469.31 1833.17 1468.75 Q1829.8 1468.2 1826.19 1467.08 L1826.19 1460.04 Q1829.32 1461.74 1832.65 1462.57 Q1835.98 1463.4 1839.7 1463.4 Q1845.7 1463.4 1849.21 1460.24 Q1852.72 1457.08 1852.72 1451.67 Q1852.72 1446.25 1849.21 1443.09 Q1845.7 1439.93 1839.7 1439.93 Q1836.89 1439.93 1834.07 1440.56 Q1831.3 1441.18 1828.38 1442.5 L1828.38 1416.46 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M2222.63 1462.4 L2234.09 1462.4 L2234.09 1422.85 L2221.62 1425.35 L2221.62 1418.96 L2234.02 1416.46 L2241.03 1416.46 L2241.03 1462.4 L2252.49 1462.4 L2252.49 1468.3 L2222.63 1468.3 L2222.63 1462.4 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M2281.65 1421.08 Q2276.24 1421.08 2273.49 1426.43 Q2270.79 1431.74 2270.79 1442.43 Q2270.79 1453.09 2273.49 1458.44 Q2276.24 1463.75 2281.65 1463.75 Q2287.11 1463.75 2289.81 1458.44 Q2292.56 1453.09 2292.56 1442.43 Q2292.56 1431.74 2289.81 1426.43 Q2287.11 1421.08 2281.65 1421.08 M2281.65 1415.52 Q2290.37 1415.52 2294.95 1422.43 Q2299.57 1429.31 2299.57 1442.43 Q2299.57 1455.52 2294.95 1462.43 Q2290.37 1469.31 2281.65 1469.31 Q2272.94 1469.31 2268.32 1462.43 Q2263.74 1455.52 2263.74 1442.43 Q2263.74 1429.31 2268.32 1422.43 Q2272.94 1415.52 2281.65 1415.52 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M2311.9 1459.48 L2319.22 1459.48 L2319.22 1468.3 L2311.9 1468.3 L2311.9 1459.48 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M2349.5 1421.08 Q2344.08 1421.08 2341.34 1426.43 Q2338.63 1431.74 2338.63 1442.43 Q2338.63 1453.09 2341.34 1458.44 Q2344.08 1463.75 2349.5 1463.75 Q2354.95 1463.75 2357.66 1458.44 Q2360.4 1453.09 2360.4 1442.43 Q2360.4 1431.74 2357.66 1426.43 Q2354.95 1421.08 2349.5 1421.08 M2349.5 1415.52 Q2358.22 1415.52 2362.8 1422.43 Q2367.42 1429.31 2367.42 1442.43 Q2367.42 1455.52 2362.8 1462.43 Q2358.22 1469.31 2349.5 1469.31 Q2340.79 1469.31 2336.17 1462.43 Q2331.58 1455.52 2331.58 1442.43 Q2331.58 1429.31 2336.17 1422.43 Q2340.79 1415.52 2349.5 1415.52 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M1326.36 1585.82 Q1322.75 1595.08 1319.32 1597.9 Q1315.9 1600.73 1310.15 1600.73 L1303.35 1600.73 L1303.35 1593.6 L1308.35 1593.6 Q1311.87 1593.6 1313.81 1591.93 Q1315.76 1590.26 1318.12 1584.06 L1319.65 1580.17 L1298.67 1529.15 L1307.7 1529.15 L1323.9 1569.71 L1340.11 1529.15 L1349.14 1529.15 L1326.36 1585.82 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  295.054,1242.31 2352.76,1242.31 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  295.054,953.003 2352.76,953.003 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  295.054,663.697 2352.76,663.697 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  295.054,374.391 2352.76,374.391 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  295.054,85.0853 2352.76,85.0853 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  295.054,1384.3 295.054,47.2441 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  295.054,1242.31 313.952,1242.31 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  295.054,953.003 313.952,953.003 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  295.054,663.697 313.952,663.697 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  295.054,374.391 313.952,374.391 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  295.054,85.0853 313.952,85.0853 \n",
       "  \"/>\n",
       "<path clip-path=\"url(#clip500)\" d=\"M241.137 1221.01 Q235.721 1221.01 232.978 1226.35 Q230.269 1231.67 230.269 1242.36 Q230.269 1253.02 232.978 1258.37 Q235.721 1263.68 241.137 1263.68 Q246.589 1263.68 249.297 1258.37 Q252.04 1253.02 252.04 1242.36 Q252.04 1231.67 249.297 1226.35 Q246.589 1221.01 241.137 1221.01 M241.137 1215.45 Q249.853 1215.45 254.436 1222.36 Q259.054 1229.24 259.054 1242.36 Q259.054 1255.45 254.436 1262.36 Q249.853 1269.24 241.137 1269.24 Q232.422 1269.24 227.804 1262.36 Q223.221 1255.45 223.221 1242.36 Q223.221 1229.24 227.804 1222.36 Q232.422 1215.45 241.137 1215.45 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M188.429 973.02 L212.908 973.02 L212.908 978.923 L179.992 978.923 L179.992 973.02 Q183.985 968.888 190.86 961.944 Q197.77 954.965 199.54 952.951 Q202.908 949.166 204.228 946.562 Q205.582 943.923 205.582 941.388 Q205.582 937.256 202.665 934.652 Q199.783 932.048 195.131 932.048 Q191.832 932.048 188.152 933.194 Q184.506 934.34 180.339 936.666 L180.339 929.583 Q184.575 927.881 188.256 927.013 Q191.936 926.145 194.992 926.145 Q203.047 926.145 207.839 930.173 Q212.631 934.201 212.631 940.937 Q212.631 944.131 211.415 947.013 Q210.235 949.86 207.075 953.749 Q206.207 954.756 201.554 959.583 Q196.901 964.374 188.429 973.02 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M227.7 927.083 L255.235 927.083 L255.235 932.985 L234.124 932.985 L234.124 945.694 Q235.651 945.173 237.179 944.93 Q238.707 944.652 240.235 944.652 Q248.915 944.652 253.985 949.409 Q259.054 954.166 259.054 962.291 Q259.054 970.659 253.846 975.312 Q248.637 979.93 239.158 979.93 Q235.894 979.93 232.492 979.374 Q229.124 978.819 225.512 977.707 L225.512 970.659 Q228.637 972.36 231.971 973.194 Q235.304 974.027 239.019 974.027 Q245.026 974.027 248.533 970.867 Q252.04 967.708 252.04 962.291 Q252.04 956.874 248.533 953.715 Q245.026 950.555 239.019 950.555 Q236.207 950.555 233.394 951.18 Q230.617 951.805 227.7 953.124 L227.7 927.083 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M180.964 637.777 L208.499 637.777 L208.499 643.68 L187.388 643.68 L187.388 656.388 Q188.915 655.867 190.443 655.624 Q191.971 655.346 193.499 655.346 Q202.179 655.346 207.249 660.103 Q212.318 664.86 212.318 672.985 Q212.318 681.353 207.11 686.006 Q201.901 690.624 192.422 690.624 Q189.158 690.624 185.756 690.068 Q182.388 689.513 178.777 688.402 L178.777 681.353 Q181.902 683.054 185.235 683.888 Q188.568 684.721 192.283 684.721 Q198.29 684.721 201.797 681.561 Q205.304 678.402 205.304 672.985 Q205.304 667.568 201.797 664.409 Q198.29 661.249 192.283 661.249 Q189.471 661.249 186.658 661.874 Q183.881 662.499 180.964 663.818 L180.964 637.777 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M241.137 642.395 Q235.721 642.395 232.978 647.742 Q230.269 653.055 230.269 663.749 Q230.269 674.409 232.978 679.756 Q235.721 685.068 241.137 685.068 Q246.589 685.068 249.297 679.756 Q252.04 674.409 252.04 663.749 Q252.04 653.055 249.297 647.742 Q246.589 642.395 241.137 642.395 M241.137 636.839 Q249.853 636.839 254.436 643.749 Q259.054 650.624 259.054 663.749 Q259.054 676.839 254.436 683.749 Q249.853 690.624 241.137 690.624 Q232.422 690.624 227.804 683.749 Q223.221 676.839 223.221 663.749 Q223.221 650.624 227.804 643.749 Q232.422 636.839 241.137 636.839 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M180.617 348.471 L213.95 348.471 L213.95 351.457 L195.131 400.311 L187.804 400.311 L205.513 354.374 L180.617 354.374 L180.617 348.471 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M227.7 348.471 L255.235 348.471 L255.235 354.374 L234.124 354.374 L234.124 367.082 Q235.651 366.561 237.179 366.318 Q238.707 366.04 240.235 366.04 Q248.915 366.04 253.985 370.797 Q259.054 375.554 259.054 383.679 Q259.054 392.047 253.846 396.7 Q248.637 401.318 239.158 401.318 Q235.894 401.318 232.492 400.762 Q229.124 400.207 225.512 399.096 L225.512 392.047 Q228.637 393.749 231.971 394.582 Q235.304 395.415 239.019 395.415 Q245.026 395.415 248.533 392.256 Q252.04 389.096 252.04 383.679 Q252.04 378.263 248.533 375.103 Q245.026 371.943 239.019 371.943 Q236.207 371.943 233.394 372.568 Q230.617 373.193 227.7 374.513 L227.7 348.471 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M136.867 105.103 L148.325 105.103 L148.325 65.5541 L135.86 68.0541 L135.86 61.6653 L148.256 59.1653 L155.27 59.1653 L155.27 105.103 L166.728 105.103 L166.728 111.005 L136.867 111.005 L136.867 105.103 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M195.895 63.7833 Q190.478 63.7833 187.735 69.1305 Q185.027 74.443 185.027 85.1374 Q185.027 95.797 187.735 101.144 Q190.478 106.457 195.895 106.457 Q201.346 106.457 204.054 101.144 Q206.797 95.797 206.797 85.1374 Q206.797 74.443 204.054 69.1305 Q201.346 63.7833 195.895 63.7833 M195.895 58.2278 Q204.61 58.2278 209.193 65.1375 Q213.811 72.0124 213.811 85.1374 Q213.811 98.2276 209.193 105.137 Q204.61 112.012 195.895 112.012 Q187.179 112.012 182.561 105.137 Q177.978 98.2276 177.978 85.1374 Q177.978 72.0124 182.561 65.1375 Q187.179 58.2278 195.895 58.2278 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M241.137 63.7833 Q235.721 63.7833 232.978 69.1305 Q230.269 74.443 230.269 85.1374 Q230.269 95.797 232.978 101.144 Q235.721 106.457 241.137 106.457 Q246.589 106.457 249.297 101.144 Q252.04 95.797 252.04 85.1374 Q252.04 74.443 249.297 69.1305 Q246.589 63.7833 241.137 63.7833 M241.137 58.2278 Q249.853 58.2278 254.436 65.1375 Q259.054 72.0124 259.054 85.1374 Q259.054 98.2276 254.436 105.137 Q249.853 112.012 241.137 112.012 Q232.422 112.012 227.804 105.137 Q223.221 98.2276 223.221 85.1374 Q223.221 72.0124 227.804 65.1375 Q232.422 58.2278 241.137 58.2278 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M83.9389 741.374 Q93.1982 744.985 96.0222 748.411 Q98.8463 751.837 98.8463 757.577 L98.8463 764.383 L91.7167 764.383 L91.7167 759.383 Q91.7167 755.864 90.05 753.92 Q88.3834 751.975 82.1797 749.614 L78.2908 748.087 L27.2726 769.059 L27.2726 760.031 L67.8279 743.827 L27.2726 727.624 L27.2726 718.596 L83.9389 741.374 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M83.9389 685.263 Q93.1982 688.874 96.0222 692.3 Q98.8463 695.726 98.8463 701.466 L98.8463 708.272 L91.7167 708.272 L91.7167 703.272 Q91.7167 699.754 90.05 697.809 Q88.3834 695.865 82.1797 693.504 L78.2908 691.976 L27.2726 712.948 L27.2726 703.92 L67.8279 687.717 L27.2726 671.513 L27.2726 662.485 L83.9389 685.263 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><polyline clip-path=\"url(#clip502)\" style=\"stroke:#808080; stroke-linecap:round; stroke-linejoin:round; stroke-width:20; stroke-opacity:1; fill:none\" points=\"\n",
       "  353.291,1242.31 372.899,1242.19 392.508,1241.84 412.116,1241.25 431.724,1240.42 451.333,1239.36 470.941,1238.06 490.549,1236.52 510.158,1234.75 529.766,1232.74 \n",
       "  549.374,1230.5 568.983,1228.02 588.591,1225.31 608.2,1222.35 627.808,1219.17 647.416,1215.74 667.025,1212.08 686.633,1208.19 706.241,1204.05 725.85,1199.68 \n",
       "  745.458,1195.08 765.066,1190.24 784.675,1185.16 804.283,1179.85 823.892,1174.3 843.5,1168.51 863.108,1162.49 882.717,1156.23 902.325,1149.74 921.933,1143.01 \n",
       "  941.542,1136.04 961.15,1128.84 980.759,1121.4 1000.37,1113.73 1019.98,1105.82 1039.58,1097.67 1059.19,1089.29 1078.8,1080.67 1098.41,1071.81 1118.02,1062.72 \n",
       "  1137.63,1053.39 1157.23,1043.83 1176.84,1034.03 1196.45,1023.99 1216.06,1013.72 1235.67,1003.21 1255.28,992.468 1274.88,981.488 1294.49,970.271 1314.1,958.818 \n",
       "  1333.71,947.129 1353.32,935.203 1372.93,923.042 1392.53,910.644 1412.14,898.011 1431.75,885.141 1451.36,872.035 1470.97,858.693 1490.58,845.114 1510.18,831.3 \n",
       "  1529.79,817.25 1549.4,802.963 1569.01,788.44 1588.62,773.681 1608.23,758.686 1627.83,743.455 1647.44,727.987 1667.05,712.284 1686.66,696.344 1706.27,680.168 \n",
       "  1725.88,663.756 1745.48,647.108 1765.09,630.224 1784.7,613.103 1804.31,595.747 1823.92,578.154 1843.53,560.325 1863.13,542.26 1882.74,523.959 1902.35,505.421 \n",
       "  1921.96,486.648 1941.57,467.638 1961.18,448.393 1980.79,428.911 2000.39,409.193 2020,389.239 2039.61,369.048 2059.22,348.622 2078.83,327.959 2098.44,307.061 \n",
       "  2118.04,285.926 2137.65,264.555 2157.26,242.948 2176.87,221.104 2196.48,199.025 2216.09,176.709 2235.69,154.157 2255.3,131.37 2274.91,108.345 2294.52,85.0853 \n",
       "  \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:8; stroke-opacity:1; fill:none\" points=\"\n",
       "  353.291,1346.46 372.899,1339.45 392.508,1332.43 412.116,1325.42 431.724,1318.4 451.333,1311.39 470.941,1304.38 490.549,1297.36 510.158,1290.35 529.766,1283.34 \n",
       "  549.374,1276.32 568.983,1269.31 588.591,1262.3 608.2,1255.28 627.808,1248.27 647.416,1241.26 667.025,1234.24 686.633,1227.23 706.241,1220.22 725.85,1213.2 \n",
       "  745.458,1206.19 765.066,1199.18 784.675,1192.16 804.283,1185.15 823.892,1178.14 843.5,1171.12 863.108,1164.11 882.717,1157.09 902.325,1150.08 921.933,1143.07 \n",
       "  941.542,1136.05 961.15,1129.04 980.759,1122.03 1000.37,1115.01 1019.98,1108 1039.58,1100.99 1059.19,1093.97 1078.8,1086.96 1098.41,1079.95 1118.02,1072.93 \n",
       "  1137.63,1065.92 1157.23,1058.91 1176.84,1051.89 1196.45,1044.88 1216.06,1037.87 1235.67,1030.85 1255.28,1023.84 1274.88,1016.83 1294.49,1009.81 1314.1,1002.8 \n",
       "  1333.71,995.785 1353.32,988.771 1372.93,981.758 1392.53,974.745 1412.14,967.731 1431.75,960.718 1451.36,953.704 1470.97,946.691 1490.58,939.677 1510.18,932.664 \n",
       "  1529.79,925.65 1549.4,918.637 1569.01,911.623 1588.62,904.61 1608.23,897.596 1627.83,890.583 1647.44,883.569 1667.05,876.556 1686.66,869.542 1706.27,862.529 \n",
       "  1725.88,855.515 1745.48,848.502 1765.09,841.488 1784.7,834.475 1804.31,827.462 1823.92,820.448 1843.53,813.435 1863.13,806.421 1882.74,799.408 1902.35,792.394 \n",
       "  1921.96,785.381 1941.57,778.367 1961.18,771.354 1980.79,764.34 2000.39,757.327 2020,750.313 2039.61,743.3 2059.22,736.286 2078.83,729.273 2098.44,722.259 \n",
       "  2118.04,715.246 2137.65,708.232 2157.26,701.219 2176.87,694.206 2196.48,687.192 2216.09,680.179 2235.69,673.165 2255.3,666.152 2274.91,659.138 2294.52,652.125 \n",
       "  \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip502)\" style=\"stroke:#0000ff; stroke-linecap:round; stroke-linejoin:round; stroke-width:8; stroke-opacity:1; fill:none\" stroke-dasharray=\"32, 20\" points=\"\n",
       "  353.291,1242.31 372.899,1238.8 392.508,1235.3 412.116,1231.79 431.724,1228.28 451.333,1224.77 470.941,1221.27 490.549,1217.76 510.158,1214.25 529.766,1210.75 \n",
       "  549.374,1207.24 568.983,1203.73 588.591,1200.23 608.2,1196.72 627.808,1193.21 647.416,1189.71 667.025,1186.2 686.633,1182.69 706.241,1179.19 725.85,1175.68 \n",
       "  745.458,1172.17 765.066,1168.67 784.675,1165.16 804.283,1161.65 823.892,1158.15 843.5,1154.64 863.108,1151.13 882.717,1147.63 902.325,1144.12 921.933,1140.61 \n",
       "  941.542,1137.11 961.15,1133.6 980.759,1130.09 1000.37,1126.59 1019.98,1123.08 1039.58,1119.57 1059.19,1116.07 1078.8,1112.56 1098.41,1109.05 1118.02,1105.55 \n",
       "  1137.63,1102.04 1157.23,1098.53 1176.84,1095.03 1196.45,1091.52 1216.06,1088.01 1235.67,1084.51 1255.28,1081 1274.88,1077.49 1294.49,1073.99 1314.1,1070.48 \n",
       "  1333.71,1066.97 1353.32,1063.46 1372.93,1059.96 1392.53,1056.45 1412.14,1052.94 1431.75,1049.44 1451.36,1045.93 1470.97,1042.42 1490.58,1038.92 1510.18,1035.41 \n",
       "  1529.79,1031.9 1549.4,1028.4 1569.01,1024.89 1588.62,1021.38 1608.23,1017.88 1627.83,1014.37 1647.44,1010.86 1667.05,1007.36 1686.66,1003.85 1706.27,1000.34 \n",
       "  1725.88,996.837 1745.48,993.33 1765.09,989.823 1784.7,986.317 1804.31,982.81 1823.92,979.303 1843.53,975.797 1863.13,972.29 1882.74,968.783 1902.35,965.276 \n",
       "  1921.96,961.77 1941.57,958.263 1961.18,954.756 1980.79,951.249 2000.39,947.743 2020,944.236 2039.61,940.729 2059.22,937.222 2078.83,933.716 2098.44,930.209 \n",
       "  2118.04,926.702 2137.65,923.195 2157.26,919.689 2176.87,916.182 2196.48,912.675 2216.09,909.169 2235.69,905.662 2255.3,902.155 2274.91,898.648 2294.52,895.142 \n",
       "  \n",
       "  \"/>\n",
       "<path clip-path=\"url(#clip500)\" d=\"\n",
       "M363.644 402.853 L779.448 402.853 L779.448 91.8126 L363.644 91.8126  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:4; stroke-opacity:0; fill:none\" points=\"\n",
       "  363.644,402.853 779.448,402.853 779.448,91.8126 363.644,91.8126 363.644,402.853 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip500)\" style=\"stroke:#808080; stroke-linecap:round; stroke-linejoin:round; stroke-width:30; stroke-opacity:1; fill:none\" points=\"\n",
       "  386.507,169.573 523.687,169.573 \n",
       "  \"/>\n",
       "<path clip-path=\"url(#clip500)\" d=\"M582.592 174.451 L582.592 177.576 L553.217 177.576 Q553.634 184.173 557.176 187.645 Q560.752 191.083 567.106 191.083 Q570.787 191.083 574.224 190.18 Q577.697 189.277 581.099 187.472 L581.099 193.513 Q577.662 194.972 574.051 195.736 Q570.44 196.5 566.724 196.5 Q557.419 196.5 551.967 191.083 Q546.551 185.666 546.551 176.43 Q546.551 166.882 551.69 161.291 Q556.863 155.666 565.613 155.666 Q573.46 155.666 578.009 160.736 Q582.592 165.771 582.592 174.451 M576.203 172.576 Q576.134 167.333 573.252 164.208 Q570.405 161.083 565.683 161.083 Q560.335 161.083 557.106 164.104 Q553.912 167.125 553.426 172.611 L576.203 172.576 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M624.155 156.604 L610.092 175.527 L624.884 195.493 L617.349 195.493 L606.03 180.215 L594.71 195.493 L587.176 195.493 L602.28 175.146 L588.46 156.604 L595.995 156.604 L606.307 170.458 L616.62 156.604 L624.155 156.604 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M651.585 175.944 Q643.842 175.944 640.856 177.715 Q637.87 179.486 637.87 183.757 Q637.87 187.159 640.092 189.173 Q642.349 191.152 646.203 191.152 Q651.516 191.152 654.71 187.402 Q657.939 183.618 657.939 177.368 L657.939 175.944 L651.585 175.944 M664.328 173.305 L664.328 195.493 L657.939 195.493 L657.939 189.59 Q655.752 193.132 652.488 194.833 Q649.224 196.5 644.502 196.5 Q638.53 196.5 634.988 193.166 Q631.481 189.798 631.481 184.173 Q631.481 177.611 635.856 174.277 Q640.266 170.944 648.981 170.944 L657.939 170.944 L657.939 170.319 Q657.939 165.909 655.022 163.514 Q652.141 161.083 646.898 161.083 Q643.564 161.083 640.405 161.882 Q637.245 162.68 634.328 164.278 L634.328 158.375 Q637.835 157.021 641.134 156.361 Q644.432 155.666 647.557 155.666 Q655.995 155.666 660.161 160.041 Q664.328 164.416 664.328 173.305 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M705.474 158.097 L705.474 164.069 Q702.765 162.576 700.022 161.847 Q697.314 161.083 694.536 161.083 Q688.321 161.083 684.883 165.041 Q681.446 168.965 681.446 176.083 Q681.446 183.201 684.883 187.159 Q688.321 191.083 694.536 191.083 Q697.314 191.083 700.022 190.354 Q702.765 189.59 705.474 188.097 L705.474 194 Q702.8 195.25 699.918 195.875 Q697.071 196.5 693.842 196.5 Q685.057 196.5 679.883 190.979 Q674.71 185.458 674.71 176.083 Q674.71 166.569 679.918 161.118 Q685.161 155.666 694.258 155.666 Q697.21 155.666 700.022 156.291 Q702.835 156.882 705.474 158.097 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M722.904 145.562 L722.904 156.604 L736.064 156.604 L736.064 161.569 L722.904 161.569 L722.904 182.68 Q722.904 187.437 724.189 188.791 Q725.508 190.145 729.501 190.145 L736.064 190.145 L736.064 195.493 L729.501 195.493 Q722.105 195.493 719.293 192.75 Q716.48 189.972 716.48 182.68 L716.48 161.569 L711.793 161.569 L711.793 156.604 L716.48 156.604 L716.48 145.562 L722.904 145.562 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><polyline clip-path=\"url(#clip500)\" style=\"stroke:#000000; stroke-linecap:round; stroke-linejoin:round; stroke-width:12; stroke-opacity:1; fill:none\" points=\"\n",
       "  386.507,247.333 523.687,247.333 \n",
       "  \"/>\n",
       "<path clip-path=\"url(#clip500)\" d=\"M546.551 221.413 L590.405 221.413 L590.405 227.315 L572.002 227.315 L572.002 273.253 L564.954 273.253 L564.954 227.315 L546.551 227.315 L546.551 221.413 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M602.801 253.704 Q595.058 253.704 592.071 255.475 Q589.085 257.246 589.085 261.517 Q589.085 264.919 591.308 266.933 Q593.564 268.912 597.419 268.912 Q602.731 268.912 605.926 265.162 Q609.155 261.378 609.155 255.128 L609.155 253.704 L602.801 253.704 M615.544 251.065 L615.544 273.253 L609.155 273.253 L609.155 267.35 Q606.967 270.892 603.703 272.593 Q600.439 274.26 595.717 274.26 Q589.745 274.26 586.203 270.926 Q582.696 267.558 582.696 261.933 Q582.696 255.371 587.071 252.037 Q591.481 248.704 600.196 248.704 L609.155 248.704 L609.155 248.079 Q609.155 243.669 606.238 241.274 Q603.356 238.843 598.113 238.843 Q594.78 238.843 591.62 239.642 Q588.46 240.44 585.544 242.038 L585.544 236.135 Q589.051 234.781 592.349 234.121 Q595.648 233.426 598.773 233.426 Q607.21 233.426 611.377 237.801 Q615.544 242.176 615.544 251.065 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M644.884 276.864 Q642.175 283.808 639.606 285.926 Q637.036 288.044 632.731 288.044 L627.627 288.044 L627.627 282.697 L631.377 282.697 Q634.016 282.697 635.474 281.447 Q636.932 280.197 638.703 275.544 L639.849 272.628 L624.12 234.364 L630.891 234.364 L643.043 264.78 L655.196 234.364 L661.967 234.364 L644.884 276.864 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M670.786 219.225 L677.175 219.225 L677.175 273.253 L670.786 273.253 L670.786 219.225 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M705.612 238.843 Q700.474 238.843 697.488 242.871 Q694.501 246.864 694.501 253.843 Q694.501 260.822 697.453 264.85 Q700.439 268.843 705.612 268.843 Q710.717 268.843 713.703 264.815 Q716.689 260.787 716.689 253.843 Q716.689 246.933 713.703 242.906 Q710.717 238.843 705.612 238.843 M705.612 233.426 Q713.946 233.426 718.703 238.843 Q723.46 244.26 723.46 253.843 Q723.46 263.392 718.703 268.843 Q713.946 274.26 705.612 274.26 Q697.244 274.26 692.488 268.843 Q687.765 263.392 687.765 253.843 Q687.765 244.26 692.488 238.843 Q697.244 233.426 705.612 233.426 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M756.584 240.336 Q755.508 239.711 754.223 239.433 Q752.973 239.121 751.446 239.121 Q746.029 239.121 743.112 242.663 Q740.23 246.169 740.23 252.767 L740.23 273.253 L733.807 273.253 L733.807 234.364 L740.23 234.364 L740.23 240.406 Q742.244 236.864 745.473 235.163 Q748.703 233.426 753.321 233.426 Q753.98 233.426 754.779 233.531 Q755.578 233.6 756.55 233.774 L756.584 240.336 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><polyline clip-path=\"url(#clip500)\" style=\"stroke:#0000ff; stroke-linecap:round; stroke-linejoin:round; stroke-width:12; stroke-opacity:1; fill:none\" stroke-dasharray=\"48, 30\" points=\"\n",
       "  386.507,325.093 523.687,325.093 \n",
       "  \"/>\n",
       "<path clip-path=\"url(#clip500)\" d=\"M567.315 354.624 Q564.606 361.568 562.037 363.686 Q559.467 365.804 555.162 365.804 L550.058 365.804 L550.058 360.457 L553.808 360.457 Q556.447 360.457 557.905 359.207 Q559.363 357.957 561.134 353.304 L562.28 350.388 L546.551 312.124 L553.322 312.124 L565.474 342.54 L577.627 312.124 L584.398 312.124 L567.315 354.624 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip500)\" d=\"M615.37 323.061 Q620.405 324.138 623.217 327.541 Q626.064 330.943 626.064 335.943 Q626.064 343.617 620.787 347.818 Q615.509 352.02 605.787 352.02 Q602.523 352.02 599.051 351.36 Q595.613 350.735 591.933 349.45 L591.933 342.679 Q594.849 344.381 598.321 345.249 Q601.794 346.117 605.578 346.117 Q612.175 346.117 615.613 343.513 Q619.085 340.909 619.085 335.943 Q619.085 331.36 615.856 328.791 Q612.662 326.186 606.932 326.186 L600.891 326.186 L600.891 320.423 L607.21 320.423 Q612.384 320.423 615.127 318.374 Q617.87 316.291 617.87 312.402 Q617.87 308.409 615.023 306.291 Q612.21 304.138 606.932 304.138 Q604.051 304.138 600.752 304.763 Q597.453 305.388 593.495 306.707 L593.495 300.457 Q597.488 299.346 600.96 298.791 Q604.467 298.235 607.557 298.235 Q615.544 298.235 620.196 301.881 Q624.849 305.492 624.849 311.673 Q624.849 315.978 622.384 318.964 Q619.919 321.916 615.37 323.061 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /></svg>\n"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = LinRange(0,10,100)\n",
    "\n",
    "y0 = 3.\n",
    "y2 = y.^2\n",
    "y0y = y0 * y\n",
    "yta = y0^2 .+ 2*y0*(y.-y0)\n",
    "\n",
    "plt.resetfontsizes(); plt.scalefontsizes(1.5)\n",
    "plt.plot( y,y2,  color=\"grey\",  lw=5, label=\"exact\")\n",
    "plt.plot!(y,yta, color=\"black\", lw=2, label=\"Taylor\")\n",
    "plt.plot!(y,y0y, color=\"blue\",  lw=2, linestyle=:dash)\n",
    "plt.plot!(xlabel=\"y\", ylabel=\"yy\", foreground_color_legend=nothing)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Nonuniform grids\n",
    "#### Method 1\n",
    "* Set an arbitrary grid with arbitrary $\\Delta x$ spacing between points.\n",
    "\n",
    "```\n",
    " *     *                         * \n",
    "i-1    i                        i+1\n",
    "```\n",
    "\n",
    "* Let $\\Delta x_{i-1} = x_i - x_{i-1}$, and $\\Delta x_{i} = x_{i+1}-x_i$.\n",
    "* Then a central difference approximation is \n",
    "$$f^{\\prime}(x_i) = f_i^{\\prime} \\approx \\frac{f_{i+1}-f_{i-1}}{\\Delta x_{i-1} + \\Delta x_i}.$$\n",
    "    * A Taylor Series gives second order when $\\Delta x_{i-1}=\\Delta x_i$, but only first order when $\\Delta x_{i-1}\\ne \\Delta x_i$.\n",
    "        * These are second and first order **asymptotically** as $\\Delta x\\rightarrow 0$. \n",
    "        * In practice, accuracy is not severely compromized if $\\Delta x_{i-1}$ is not too different from $\\Delta x_i$.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "\n",
    "* For a second derivative, we have\n",
    "$$f^{\\prime\\prime}_i\\approx \\frac{\\frac{f_{i+1}-f_i}{\\Delta x_i}-\\frac{f_i-f_{i-1}}{\\Delta x_{i-1}}}{\\frac{\\Delta x_{i-1}+\\Delta x_i}{2}}.$$\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "#### Method 2\n",
    "* Stretch the grid **analytically**\n",
    "* Let $x$ be the nonuniform grid and\n",
    "* Let $\\eta$ be a corresponding uniform grid.\n",
    "* For example\n",
    "$$\\eta = \\ln(x+1) \\rightarrow x = e^{\\eta} - 1.$$\n",
    "<img src=\"https://ignite.byu.edu/cbe541/lectures/figs/l21_f01.png\" width=\"200\">\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "\n",
    "* Then \n",
    "    $$ \\frac{dy}{dx} = \\frac{dy}{d\\eta}\\frac{d\\eta}{dx} = \\frac{dy}{d\\eta}\\left(\\frac{1}{x+1}\\right).$$\n",
    "    * This allows us to transform all the $dy/dx$ derivatives on the nonuniform grid to $dy/d\\eta$ derivatives on a uniform grid times some known factor $1/(x+1)$ at any given point. \n",
    "    * So, if we are evaluating $dy/dx$ at point $i$, we would have \n",
    "    $$y^{\\prime}_i = \\frac{y_{i+1}-y_{i-1}}{\\Delta \\eta}\\left(\\frac{1}{x_i+1}\\right).$$\n",
    "* This works great, and is easy to use. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### Questions\n",
    "- What would you do to have an arbitrary grid spacing that is not defined by some known function?\n",
    "- Could you develop a second order approximation to a central derivative on a nonuniform grid?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "Julia 1.8.3",
   "language": "julia",
   "name": "julia-1.8"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.8.3"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
