589 lines
59 KiB
Plaintext
589 lines
59 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Week 3 - Fitting a curve"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Plots.GRBackend()"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# You may need this setup\n",
|
||
|
"using Plots\n",
|
||
|
"gr() # Activate the GR backend for use with Plots"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"using DelimitedFiles"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Import the supplied data representing 15 pairs to x- and y-values. "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"data_tofit = readdlm(\"Week3_PR_Data.dat\", '\\t');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[0.1268004831284406, -1.6416953879765301]\n",
|
||
|
"[0.5013092807380928, -0.9776975375269383]\n",
|
||
|
"[1.5280121125586477, 0.5277112203195138]\n",
|
||
|
"[1.7001225303407743, 1.711524991194374]\n",
|
||
|
"[1.9924936253216172, 1.8910000148140624]\n",
|
||
|
"[2.706075824201991, -0.46342779446395]\n",
|
||
|
"[2.9949319274309043, -0.4435666186385725]\n",
|
||
|
"[3.4918528112833935, -1.275179133203867]\n",
|
||
|
"[3.501191722475427, -0.6904995966451337]\n",
|
||
|
"[4.459924502120439, -5.51613079927097]\n",
|
||
|
"[4.936965850879389, -6.001703074115855]\n",
|
||
|
"[5.023289852369695, -8.364169009651015]\n",
|
||
|
"[5.042336980089736, -7.924477516763416]\n",
|
||
|
"[5.507392850419521, -10.774823709545498]\n",
|
||
|
"[5.568665171088307, -10.917187797703853]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for i = 1:size(data_tofit)[1]\n",
|
||
|
" println(data_tofit[i,:])\n",
|
||
|
"end"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"x, y = data_tofit[:,1], data_tofit[:,2];"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Then we do a scatterplot, this gives us the points the line must go through."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"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=\"clip7100\">\n",
|
||
|
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<path clip-path=\"url(#clip7100)\" 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=\"clip7101\">\n",
|
||
|
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<path clip-path=\"url(#clip7100)\" d=\"\n",
|
||
|
"M189.237 1486.45 L2352.76 1486.45 L2352.76 47.2441 L189.237 47.2441 Z\n",
|
||
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
|
||
|
"<defs>\n",
|
||
|
" <clipPath id=\"clip7102\">\n",
|
||
|
" <rect x=\"189\" y=\"47\" width=\"2165\" height=\"1440\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 202.91,1486.45 202.91,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 577.976,1486.45 577.976,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 953.041,1486.45 953.041,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 1328.11,1486.45 1328.11,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 1703.17,1486.45 1703.17,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 2078.24,1486.45 2078.24,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 189.237,1348.49 2352.76,1348.49 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 189.237,1083.47 2352.76,1083.47 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 189.237,818.461 2352.76,818.461 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 189.237,553.447 2352.76,553.447 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7102)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 189.237,288.433 2352.76,288.433 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 189.237,1486.45 2352.76,1486.45 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 189.237,1486.45 189.237,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 202.91,1486.45 202.91,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 577.976,1486.45 577.976,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 953.041,1486.45 953.041,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1328.11,1486.45 1328.11,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1703.17,1486.45 1703.17,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 2078.24,1486.45 2078.24,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 189.237,1348.49 215.199,1348.49 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 189.237,1083.47 215.199,1083.47 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 189.237,818.461 215.199,818.461 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 189.237,553.447 215.199,553.447 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7100)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 189.237,288.433 215.199,288.433 \n",
|
||
|
" \"/>\n",
|
||
|
"<path clip-path=\"url(#clip7100)\" d=\"M 0 0 M202.91 1508.44 Q199.299 1508.44 197.47 1512 Q195.665 1515.55 195.665 1522.67 Q195.665 1529.78 197.47 1533.35 Q199.299 1536.89 202.91 1536.89 Q206.544 1536.89 208.35 1533.35 Q210.179 1529.78 210.179 1522.67 Q210.179 1515.55 208.35 1512 Q206.544 1508.44 202.91 1508.44 M202.91 1504.73 Q208.72 1504.73 211.776 1509.34 Q214.855 1513.92 214.855 1522.67 Q214.855 1531.4 211.776 1536.01 Q208.72 1540.59 202.91 1540.59 Q197.1 1540.59 194.021 1536.01 Q190.966 1531.4 190.966 1522.67 Q190.966 1513.92 194.021 1509.34 Q197.1 1504.73 202.91 1504.73 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7100)\" d=\"M 0 0 M568.358 1535.98 L575.996 1535.98 L575.996 1509.62 L567.686 1511.29 L567.686 1507.03 L575.95 1505.36 L580.626 1505.36 L580.626 1535.98 L588.265 1535.98 L588.265 1539.92 L568.358 1539.92 L568.358 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7100)\" d=\"M 0 0 M947.694 1535.98 L964.013 1535.98 L964.013 1539.92 L942.069 1539.92 L942.069 1535.98 Q944.731 1533.23 949.314 1528.6 Q953.921 1523.95 955.101 1522.61 Q957.347 1520.08 958.226 1518.35 Q959.129 1516.59 959.129 1514.9 Q959.129 1512.14 957.185 1510.41 Q955.263 1508.67 952.161 1508.67 Q949.962 1508.67 947.509 1509.43 Q945.078 1510.2 942.3 1511.75 L942.3 1507.03 Q945.124 1505.89 947.578 1505.31 Q950.032 1504.73 952.069 1504.73 Q957.439 1504.73 960.634 1507.42 Q963.828 1510.11 963.828 1514.6 Q963.828 1516.73 963.018 1518.65 Q962.231 1520.54 960.124 1523.14 Q959.546 1523.81 956.444 1527.03 Q953.342 1530.22 947.694 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7100)\" d=\"M 0 0 M1332.35 1521.29 Q1335.71 1522 1337.59 1524.27 Q1339.48 1526.54 1339.48 1529.87 Q1339.48 1534.99 1335.97 1537.79 Q1332.45 1540.59 1325.97 1540.59 Q1323.79 1540.59 1321.47 1540.15 Q1319.18 1539.73 1316.73 1538.88 L1316.73 1534.36 Q1318.67 1535.5 1320.99 1536.08 Q1323.3 1536.66 1325.83 1536.66 Q1330.22 1536.66 1332.52 1534.92 Q1334.83 1533.18 1334.83 1529.87 Q1334.83 1526.82 1332.68 1525.11 Q1330.55 1523.37 1326.73 1523.37 L1322.7 1523.37 L1322.7 1519.53 L1326.91 1519.53 Q1330.36 1519.53 1332.19 1518.16 Q1334.02 1516.77 1334.02 1514.18 Q1334.02 1511.52 1332.12 1510.11 Q1330.25 1508.67 1326.73 1508.67 Q1324.81 1508.67 1322.61 1509.09 Q1320.41 1509.5 1317.77 1510.38 L1317.77 1506.22 Q1320.43 1505.48 1322.75 1505.11 Q1325.09 1504.73 1327.15 1504.73 Q1332.47 1504.73 1335.57 1507.17 Q1338.67 1509.57 1338.67 1513.69 Q1338.67 1516.56 1337.03 1518.55 Q1335.39 1520.52 1332.35 1521.29 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7100)\" d=\"M 0 0 M1706.18 1509.43 L1694.38 1527.88 L1706.18 1527.88 L1706.18 1509.43 M1704.95 1505.36 L1710.83 1505.36 L1710.83 1527.88 L1715.76 1527.88 L1715.76 1531.77 L1710.83 1531.77 L1710.83 1539.92 L1706.18 1539.92 L1706.18 1531.77 L1690.58 1531.77 L1690.58 1527.26 L1704.95 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7100)\" d=\"M 0 0 M2068.52 1505.36 L2086.87 1505.36 L2086.87 1509.3 L2072.8 1509.3 L2072.8 1517.77 Q2073.82 1517.42 2074.83 1517.26 Q2075.85 1517.07 2076.87 1517.07 Q2082.66 1517.07 2086.04 1520.24 Q2089.42 1523.42 2089.42 1528.83 Q2089.42 1534.41 2085.95 1537.51 Q2082.47 1540.59 2076.15 1540.59 Q2073.98 1540.59 2071.71 1540.22 Q2069.46 1539.85 2067.06 1539.11 L2067.06 1534.41 Q2069.14 1535.54 2071.36 1536.1 Q2073.58 1536.66 2076.06 1536.66 Q2080.07 1536.66 2082.4 1534.55 Q2084.74 1532.44 2084.74 1528.83 Q2084.74 1525.22 2082.4 1523.11 Q2080.07 1521.01 2076.06 1521.01 Q2074.19 1521.01 2072.31 1521.42 Q2070.46 1521.84 2068.52 1522.72 L2068.52 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7100)\" d=\"M 0 0 M62.9921 1350.88 L75.4689 1350.88 L75.4689 1354.68 L62.9921 1354.68 L62.9921 1350.88 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7100)\" d=\"M 0 0 M81.3485 1361.83 L88.9874 1361.83
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"390.934\" cy=\"392.074\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"776.015\" cy=\"232.493\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"840.567\" cy=\"107.002\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"950.226\" cy=\"87.9763\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"1217.87\" cy=\"337.559\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"1326.21\" cy=\"335.453\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"1512.58\" cy=\"423.609\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"1516.09\" cy=\"361.63\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"1875.67\" cy=\"873.173\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"2054.6\" cy=\"924.647\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"2086.97\" cy=\"1175.08\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"2094.12\" cy=\"1128.47\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"2268.54\" cy=\"1430.62\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7102)\" cx=\"2291.52\" cy=\"1445.72\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"</svg>\n"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Plot the x and y data points using a scatter plot of the x and y array variables\n",
|
||
|
"plot(x,y,line=:scatter,legend=:false)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"For the line, we need a function, which we now define. Note that the parameters a, b, c need not be passed to the function: we will keep resetting them to try to improve the fit."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"parabfit (generic function with 1 method)"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Create a function called parabfit, with x as the argument, returning a*x^2 + b*x + c\n",
|
||
|
"function parabfit(x)\n",
|
||
|
" return a*x^2 + b*x + c\n",
|
||
|
"end"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Let's check that we do get a reasonable parabola. Choose your own interval [xmin, xmax] and parameters a, b, c. If it looks too much like a straight line, chance your choices until it does."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"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=\"clip7500\">\n",
|
||
|
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<path clip-path=\"url(#clip7500)\" 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=\"clip7501\">\n",
|
||
|
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<path clip-path=\"url(#clip7500)\" d=\"\n",
|
||
|
"M136.76 1486.45 L2352.76 1486.45 L2352.76 47.2441 L136.76 47.2441 Z\n",
|
||
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
|
||
|
"<defs>\n",
|
||
|
" <clipPath id=\"clip7502\">\n",
|
||
|
" <rect x=\"136\" y=\"47\" width=\"2217\" height=\"1440\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 408.533,1486.45 408.533,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 826.646,1486.45 826.646,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 1244.76,1486.45 1244.76,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 1662.87,1486.45 1662.87,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 2080.98,1486.45 2080.98,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 136.76,1479.38 2352.76,1479.38 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 136.76,1030.54 2352.76,1030.54 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 136.76,581.7 2352.76,581.7 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 136.76,132.86 2352.76,132.86 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 136.76,1486.45 2352.76,1486.45 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 136.76,1486.45 136.76,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 408.533,1486.45 408.533,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 826.646,1486.45 826.646,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1244.76,1486.45 1244.76,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1662.87,1486.45 1662.87,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 2080.98,1486.45 2080.98,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 136.76,1479.38 163.352,1479.38 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 136.76,1030.54 163.352,1030.54 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 136.76,581.7 163.352,581.7 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 136.76,132.86 163.352,132.86 \n",
|
||
|
" \"/>\n",
|
||
|
"<path clip-path=\"url(#clip7500)\" d=\"M 0 0 M388.545 1525.04 L401.022 1525.04 L401.022 1528.83 L388.545 1528.83 L388.545 1525.04 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M418.938 1509.43 L407.133 1527.88 L418.938 1527.88 L418.938 1509.43 M417.712 1505.36 L423.591 1505.36 L423.591 1527.88 L428.522 1527.88 L428.522 1531.77 L423.591 1531.77 L423.591 1539.92 L418.938 1539.92 L418.938 1531.77 L403.337 1531.77 L403.337 1527.26 L417.712 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M807.699 1525.04 L820.176 1525.04 L820.176 1528.83 L807.699 1528.83 L807.699 1525.04 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M829.273 1535.98 L845.592 1535.98 L845.592 1539.92 L823.648 1539.92 L823.648 1535.98 Q826.31 1533.23 830.893 1528.6 Q835.5 1523.95 836.68 1522.61 Q838.926 1520.08 839.805 1518.35 Q840.708 1516.59 840.708 1514.9 Q840.708 1512.14 838.764 1510.41 Q836.842 1508.67 833.741 1508.67 Q831.542 1508.67 829.088 1509.43 Q826.657 1510.2 823.88 1511.75 L823.88 1507.03 Q826.704 1505.89 829.157 1505.31 Q831.611 1504.73 833.648 1504.73 Q839.018 1504.73 842.213 1507.42 Q845.407 1510.11 845.407 1514.6 Q845.407 1516.73 844.597 1518.65 Q843.81 1520.54 841.704 1523.14 Q841.125 1523.81 838.023 1527.03 Q834.921 1530.22 829.273 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M1244.76 1508.44 Q1241.15 1508.44 1239.32 1512 Q1237.51 1515.55 1237.51 1522.67 Q1237.51 1529.78 1239.32 1533.35 Q1241.15 1536.89 1244.76 1536.89 Q1248.39 1536.89 1250.2 1533.35 Q1252.03 1529.78 1252.03 1522.67 Q1252.03 1515.55 1250.2 1512 Q1248.39 1508.44 1244.76 1508.44 M1244.76 1504.73 Q1250.57 1504.73 1253.62 1509.34 Q1256.7 1513.92 1256.7 1522.67 Q1256.7 1531.4 1253.62 1536.01 Q1250.57 1540.59 1244.76 1540.59 Q1238.95 1540.59 1235.87 1536.01 Q1232.81 1531.4 1232.81 1522.67 Q1232.81 1513.92 1235.87 1509.34 Q1238.95 1504.73 1244.76 1504.73 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M1657.52 1535.98 L1673.84 1535.98 L1673.84 1539.92 L1651.9 1539.92 L1651.9 1535.98 Q1654.56 1533.23 1659.14 1528.6 Q1663.75 1523.95 1664.93 1522.61 Q1667.18 1520.08 1668.06 1518.35 Q1668.96 1516.59 1668.96 1514.9 Q1668.96 1512.14 1667.01 1510.41 Q1665.09 1508.67 1661.99 1508.67 Q1659.79 1508.67 1657.34 1509.43 Q1654.91 1510.2 1652.13 1511.75 L1652.13 1507.03 Q1654.95 1505.89 1657.41 1505.31 Q1659.86 1504.73 1661.9 1504.73 Q1667.27 1504.73 1670.46 1507.42 Q1673.66 1510.11 1673.66 1514.6 Q1673.66 1516.73 1672.85 1518.65 Q1672.06 1520.54 1669.95 1523.14 Q1669.38 1523.81 1666.27 1527.03 Q1663.17 1530.22 1657.52 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M2083.99 1509.43 L2072.19 1527.88 L2083.99 1527.88 L2083.99 1509.43 M2082.77 1505.36 L2088.64 1505.36 L2088.64 1527.88 L2093.58 1527.88 L2093.58 1531.77 L2088.64 1531.77 L2088.64 1539.92 L2083.99 1539.92 L2083.99 1531.77 L2068.39 1531.77 L2068.39 1527.26 L2082.77 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M100.816 1465.18 Q97.2049 1465.18 95.3762 1468.74 Q93.5707 1472.28 93.5707 1479.41 Q93.5707 1486.52 95.3762 1490.08 Q97.2049 1493.63 100.816 1493.63 Q104.45 1493.63 106.256 1490.08 Q108.084 1486.52 108.084 1479.41 Q108.084 1472.28 106.256 1468.74 Q104.45 1465.18 100.816 1465.18 M100.816 1461.47 Q106.626 1461.47 109.682 1466.08 Q112.76 1470.66 112.76 1479.41 Q112.76 1488.14 109.682 1492.75 Q106.626 1497.33 100.816 1497.33 Q95.0058 1497.33 91.9272 1492.75 Q88.8716 1488.14 88.8716 1479.41 Q88.8716 1470.66 91.9272 1466.08 Q95.0058 1461.47 100.816 1461.47 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M65.8393 1043.88 L73.4782 1043.88 L73.4782 1017.52 L65.168 1019.19 L65.168 1014.93 L73.4319 1013.26 L78.1078
|
||
|
" 199.477,536.816 304.005,727.573 408.533,895.887 513.062,1041.76 617.59,1165.19 722.118,1266.18 826.646,1344.73 931.174,1400.83 1035.7,1434.49 1140.23,1445.72 \n",
|
||
|
" 1244.76,1434.49 1349.29,1400.83 1453.81,1344.73 1558.34,1266.18 1662.87,1165.19 1767.4,1041.76 1871.93,895.887 1976.45,727.573 2080.98,536.816 2185.51,323.617 \n",
|
||
|
" 2290.04,87.9763 \n",
|
||
|
" \"/>\n",
|
||
|
"<path clip-path=\"url(#clip7500)\" d=\"\n",
|
||
|
"M1989.74 251.724 L2280.76 251.724 L2280.76 130.764 L1989.74 130.764 Z\n",
|
||
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1989.74,251.724 2280.76,251.724 2280.76,130.764 1989.74,130.764 1989.74,251.724 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7500)\" style=\"stroke:#009af9; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 2013.74,191.244 2157.74,191.244 \n",
|
||
|
" \"/>\n",
|
||
|
"<path clip-path=\"url(#clip7500)\" d=\"M 0 0 M2195.58 210.931 Q2193.77 215.561 2192.06 216.973 Q2190.35 218.385 2187.48 218.385 L2184.08 218.385 L2184.08 214.82 L2186.58 214.82 Q2188.33 214.82 2189.31 213.987 Q2190.28 213.154 2191.46 210.052 L2192.22 208.107 L2181.74 182.598 L2186.25 182.598 L2194.35 202.876 L2202.46 182.598 L2206.97 182.598 L2195.58 210.931 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7500)\" d=\"M 0 0 M2212.85 204.589 L2220.49 204.589 L2220.49 178.223 L2212.18 179.89 L2212.18 175.631 L2220.44 173.964 L2225.12 173.964 L2225.12 204.589 L2232.76 204.589 L2232.76 208.524 L2212.85 208.524 L2212.85 204.589 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /></svg>\n"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Create variables a, b and c, assigning each the value 1\n",
|
||
|
"a = 1\n",
|
||
|
"b = 1\n",
|
||
|
"c = 1\n",
|
||
|
"\n",
|
||
|
"f = Array{Float64}(undef,length(-5:0.5:5))\n",
|
||
|
"\n",
|
||
|
"# Plot the function parabfit, for x values between -5 and 5 \n",
|
||
|
"i = 1\n",
|
||
|
"for j = -5:0.5:5\n",
|
||
|
" f[i] = parabfit(j) \n",
|
||
|
" i = i + 1\n",
|
||
|
"end\n",
|
||
|
"\n",
|
||
|
"plot(-5:0.5:5,f)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Now we choose a, b, c and plot the curve together with the points. \n",
|
||
|
"\n",
|
||
|
"Note that by looking at where the data points lie, we can deduce some of the properties for a, b, c, as follows.\n",
|
||
|
"\n",
|
||
|
"The plot must have a y-intersection that is close to 0, so c is close to 0. Also, the parabola is open downwards, so a must be negative. Finally, it has its maximum at a positive x, so b must be positive. \n",
|
||
|
"\n",
|
||
|
"Use plot() to start with the scatter plot and plot!() to add the curve for parabfit. (There are other ways to do this ...)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"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=\"clip7900\">\n",
|
||
|
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<path clip-path=\"url(#clip7900)\" 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=\"clip7901\">\n",
|
||
|
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<path clip-path=\"url(#clip7900)\" d=\"\n",
|
||
|
"M152.27 1486.45 L2352.76 1486.45 L2352.76 47.2441 L152.27 47.2441 Z\n",
|
||
|
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
|
||
|
"<defs>\n",
|
||
|
" <clipPath id=\"clip7902\">\n",
|
||
|
" <rect x=\"152\" y=\"47\" width=\"2201\" height=\"1440\"/>\n",
|
||
|
" </clipPath>\n",
|
||
|
"</defs>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 214.547,1486.45 214.547,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 560.536,1486.45 560.536,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 906.524,1486.45 906.524,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 1252.51,1486.45 1252.51,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 1598.5,1486.45 1598.5,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 1944.49,1486.45 1944.49,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 2290.48,1486.45 2290.48,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 152.27,1445.72 2352.76,1445.72 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 152.27,1043.8 2352.76,1043.8 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 152.27,641.892 2352.76,641.892 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
|
||
|
" 152.27,239.979 2352.76,239.979 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 152.27,1486.45 2352.76,1486.45 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 152.27,1486.45 152.27,47.2441 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 214.547,1486.45 214.547,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 560.536,1486.45 560.536,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 906.524,1486.45 906.524,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1252.51,1486.45 1252.51,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1598.5,1486.45 1598.5,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 1944.49,1486.45 1944.49,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 2290.48,1486.45 2290.48,1469.18 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 152.27,1445.72 178.675,1445.72 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 152.27,1043.8 178.675,1043.8 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 152.27,641.892 178.675,641.892 \n",
|
||
|
" \"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 152.27,239.979 178.675,239.979 \n",
|
||
|
" \"/>\n",
|
||
|
"<path clip-path=\"url(#clip7900)\" d=\"M 0 0 M214.547 1508.44 Q210.936 1508.44 209.108 1512 Q207.302 1515.55 207.302 1522.67 Q207.302 1529.78 209.108 1533.35 Q210.936 1536.89 214.547 1536.89 Q218.182 1536.89 219.987 1533.35 Q221.816 1529.78 221.816 1522.67 Q221.816 1515.55 219.987 1512 Q218.182 1508.44 214.547 1508.44 M214.547 1504.73 Q220.358 1504.73 223.413 1509.34 Q226.492 1513.92 226.492 1522.67 Q226.492 1531.4 223.413 1536.01 Q220.358 1540.59 214.547 1540.59 Q208.737 1540.59 205.659 1536.01 Q202.603 1531.4 202.603 1522.67 Q202.603 1513.92 205.659 1509.34 Q208.737 1504.73 214.547 1504.73 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7900)\" d=\"M 0 0 M550.918 1535.98 L558.557 1535.98 L558.557 1509.62 L550.247 1511.29 L550.247 1507.03 L558.51 1505.36 L563.186 1505.36 L563.186 1535.98 L570.825 1535.98 L570.825 1539.92 L550.918 1539.92 L550.918 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7900)\" d=\"M 0 0 M901.177 1535.98 L917.496 1535.98 L917.496 1539.92 L895.552 1539.92 L895.552 1535.98 Q898.214 1533.23 902.797 1528.6 Q907.404 1523.95 908.584 1522.61 Q910.83 1520.08 911.709 1518.35 Q912.612 1516.59 912.612 1514.9 Q912.612 1512.14 910.668 1510.41 Q908.747 1508.67 905.645 1508.67 Q903.446 1508.67 900.992 1509.43 Q898.561 1510.2 895.784 1511.75 L895.784 1507.03 Q898.608 1505.89 901.061 1505.31 Q903.515 1504.73 905.552 1504.73 Q910.922 1504.73 914.117 1507.42 Q917.311 1510.11 917.311 1514.6 Q917.311 1516.73 916.501 1518.65 Q915.714 1520.54 913.608 1523.14 Q913.029 1523.81 909.927 1527.03 Q906.825 1530.22 901.177 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7900)\" d=\"M 0 0 M1256.76 1521.29 Q1260.12 1522 1261.99 1524.27 Q1263.89 1526.54 1263.89 1529.87 Q1263.89 1534.99 1260.37 1537.79 Q1256.85 1540.59 1250.37 1540.59 Q1248.2 1540.59 1245.88 1540.15 Q1243.59 1539.73 1241.14 1538.88 L1241.14 1534.36 Q1243.08 1535.5 1245.39 1536.08 Q1247.71 1536.66 1250.23 1536.66 Q1254.63 1536.66 1256.92 1534.92 Q1259.24 1533.18 1259.24 1529.87 Q1259.24 1526.82 1257.08 1525.11 Q1254.95 1523.37 1251.14 1523.37 L1247.11 1523.37 L1247.11 1519.53 L1251.32 1519.53 Q1254.77 1519.53 1256.6 1518.16 Q1258.43 1516.77 1258.43 1514.18 Q1258.43 1511.52 1256.53 1510.11 Q1254.65 1508.67 1251.14 1508.67 Q1249.21 1508.67 1247.02 1509.09 Q1244.82 1509.5 1242.18 1510.38 L1242.18 1506.22 Q1244.84 1505.48 1247.15 1505.11 Q1249.49 1504.73 1251.55 1504.73 Q1256.88 1504.73 1259.98 1507.17 Q1263.08 1509.57 1263.08 1513.69 Q1263.08 1516.56 1261.44 1518.55 Q1259.79 1520.52 1256.76 1521.29 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7900)\" d=\"M 0 0 M1601.51 1509.43 L1589.7 1527.88 L1601.51 1527.88 L1601.51 1509.43 M1600.28 1505.36 L1606.16 1505.36 L1606.16 1527.88 L1611.09 1527.88 L1611.09 1531.77 L1606.16 1531.77 L1606.16 1539.92 L1601.51 1539.92 L1601.51 1531.77 L1585.91 1531.77 L1585.91 1527.26 L1600.28 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7900)\" d=\"M 0 0 M1934.77 1505.36 L1953.12 1505.36 L1953.12 1509.3 L1939.05 1509.3 L1939.05 1517.77 Q1940.07 1517.42 1941.09 1517.26 Q1942.11 1517.07 1943.12 1517.07 Q1948.91 1517.07 1952.29 1520.24 Q1955.67 1523.42 1955.67 1528.83 Q1955.67 1534.41 1952.2 1537.51 Q1948.73 1540.59 1942.41 1540.59 Q1940.23 1540.59 1937.96 1540.22 Q1935.72 1539.85 1933.31 1539.11 L1933.31 1534.41 Q1935.39 1535.54 1937.61 1536.1 Q1939.84 1536.66 1942.31 1536.66 Q1946.32 1536.66 1948.66 1534.55 Q1950.99 1532.44 1950.99 1528.83 Q1950.99 1525.22 1948.66 1523.11 Q1946.32 1521.01 1942.31 1521.01 Q1940.44 1521.01 1938.56 1521.42 Q1936.71 1521.84 1934.77 1522.72 L1934.77 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip7900)\" d=\"M 0 0 M2290.88 1520.78 Q2287.73 1520.78 2285.88 1522.93 Q2284.05 1525.08 2284.05 1528.83 Q2284.05 1532.56 2285.88 1534.73 Q2287.73 1536.89 2290.88 1536.89 Q2294.03 1536.89 2295.86 1534.73 Q2297.71 1532.56 2297.7
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"387.995\" cy=\"318.569\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"743.222\" cy=\"197.561\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"802.77\" cy=\"102.403\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"903.927\" cy=\"87.9763\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1150.82\" cy=\"277.231\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1250.76\" cy=\"275.634\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1422.69\" cy=\"342.481\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1425.92\" cy=\"295.483\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1757.63\" cy=\"683.379\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1922.68\" cy=\"722.411\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1952.55\" cy=\"912.312\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"1959.14\" cy=\"876.968\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"2120.04\" cy=\"1106.09\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<circle clip-path=\"url(#clip7902)\" cx=\"2141.24\" cy=\"1117.53\" r=\"14\" fill=\"#009af9\" fill-rule=\"evenodd\" fill-opacity=\"1\" stroke=\"#000000\" stroke-opacity=\"1\" stroke-width=\"3.2\"/>\n",
|
||
|
"<polyline clip-path=\"url(#clip7902)\" style=\"stroke:#e26f46; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
|
||
|
" 214.547,481.127 387.542,340.457 560.536,239.979 733.53,179.693 906.524,159.597 1079.52,179.693 1252.51,239.979 1425.51,340.457 1598.5,481.127 1771.5,661.987 \n",
|
||
|
" 1944.49,883.039 2117.48,1144.28 2290.48,1445.72 \n",
|
||
|
" \"/>\n",
|
||
|
"</svg>\n"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# More plot!() tries.\n",
|
||
|
"rangez = 0:0.5:6\n",
|
||
|
"a,b,c = -1,4,-3\n",
|
||
|
"\n",
|
||
|
"f = Array{Float64}(undef,length(rangez))\n",
|
||
|
"\n",
|
||
|
"# Plot the function parabfit, for x values between -5 and 5 \n",
|
||
|
"i = 1\n",
|
||
|
"for j = rangez\n",
|
||
|
" f[i] = parabfit(j) \n",
|
||
|
" i = i + 1\n",
|
||
|
"end\n",
|
||
|
"plot(x,y,line=:scatter,legend=:false)\n",
|
||
|
"plot!(rangez,f)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Julia 1.2.0",
|
||
|
"language": "julia",
|
||
|
"name": "julia-1.2"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"file_extension": ".jl",
|
||
|
"mimetype": "application/julia",
|
||
|
"name": "julia",
|
||
|
"version": "1.2.0"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 4
|
||
|
}
|