2020-05-22 16:18:56 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Ed's polynomial"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"y (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y(x) = x^5 + x^2 + x^3 + x^2 + x + 5"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients. A polynomial in one variable (i.e., a univariate polynomial) with constant coefficients is given by\n",
"$a_n x^n + \\dots + a_2 x^2 + a_1 x + a_0$.\n",
"The individual summands with the coefficients (usually) included are called monomials, whereas the products of the form $x_1^{a_1} \\dots x_n^{a_n}$ in the multivariate case, i.e., with the coefficients omitted, are called terms. However, the term \"monomial\" is sometimes also used to mean polynomial summands without their coefficients, and in some older works, the definitions of monomial and term are reversed. Care is therefore needed in attempting to distinguish these conflicting usages.\n",
"The highest power in a univariate polynomial is called its order, or sometimes its degree.\n",
"Any polynomial $P(x)$ with $P(0)!=0$ can be expressed as\n",
"$P(x) = P(0) product_ρ (1 - x/ρ )$, where the product runs over the roots $ρ $ of $P(ρ ) = 0$ and it is understood that multiple roots are counted with multiplicity."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"the value of y at -5 is -3200\n",
"the value of y at -4 is -1055\n",
"the value of y at -3 is -250\n",
"the value of y at -2 is -29\n",
"the value of y at -1 is 4\n",
"the value of y at 0 is 5\n",
"the value of y at 1 is 10\n",
"the value of y at 2 is 55\n",
"the value of y at 3 is 296\n",
"the value of y at 4 is 1129\n",
"the value of y at 5 is 3310\n"
]
}
],
"source": [
"for x = -5:5\n",
" println(\"the value of y at $x is $(y(x))\")\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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",
2020-05-24 00:18:32 +00:00
" <clipPath id=\"clip6800\">\n",
2020-05-22 16:18:56 +00:00
" <rect x=\"0\" y=\"0\" width=\"2400\" height=\"1600\"/>\n",
" </clipPath>\n",
"</defs>\n",
2020-05-24 00:18:32 +00:00
"<path clip-path=\"url(#clip6800)\" d=\"\n",
2020-05-22 16:18:56 +00:00
"M0 1600 L2400 1600 L2400 0 L0 0 Z\n",
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
"<defs>\n",
2020-05-24 00:18:32 +00:00
" <clipPath id=\"clip6801\">\n",
2020-05-22 16:18:56 +00:00
" <rect x=\"480\" y=\"0\" width=\"1681\" height=\"1600\"/>\n",
" </clipPath>\n",
"</defs>\n",
2020-05-24 00:18:32 +00:00
"<path clip-path=\"url(#clip6800)\" d=\"\n",
2020-05-22 16:18:56 +00:00
"M206.876 1486.45 L2352.76 1486.45 L2352.76 47.2441 L206.876 47.2441 Z\n",
" \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
"<defs>\n",
2020-05-24 00:18:32 +00:00
" <clipPath id=\"clip6802\">\n",
2020-05-22 16:18:56 +00:00
" <rect x=\"206\" y=\"47\" width=\"2147\" height=\"1440\"/>\n",
" </clipPath>\n",
"</defs>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 470.05,1486.45 470.05,47.2441 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 874.933,1486.45 874.933,47.2441 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 1279.82,1486.45 1279.82,47.2441 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 1684.7,1486.45 1684.7,47.2441 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 2089.58,1486.45 2089.58,47.2441 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,1404 2352.76,1404 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,1195.44 2352.76,1195.44 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,986.879 2352.76,986.879 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,778.317 2352.76,778.317 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,569.755 2352.76,569.755 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,361.193 2352.76,361.193 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6802)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,152.631 2352.76,152.631 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,1486.45 2352.76,1486.45 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,1486.45 206.876,47.2441 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 470.05,1486.45 470.05,1469.18 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 874.933,1486.45 874.933,1469.18 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 1279.82,1486.45 1279.82,1469.18 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 1684.7,1486.45 1684.7,1469.18 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 2089.58,1486.45 2089.58,1469.18 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,1404 232.626,1404 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,1195.44 232.626,1195.44 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,986.879 232.626,986.879 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,778.317 232.626,778.317 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,569.755 232.626,569.755 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,361.193 232.626,361.193 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<polyline clip-path=\"url(#clip6800)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
2020-05-22 16:18:56 +00:00
" 206.876,152.631 232.626,152.631 \n",
" \"/>\n",
2020-05-24 00:18:32 +00:00
"<path clip-path=\"url(#clip6800)\" d=\"M 0 0 M450.061 1525.04 L462.538 1525.04 L462.538 1528.83 L450.061 1528.83 L450.061 1525.04 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M480.455 1509.43 L468.649 1527.88 L480.455 1527.88 L480.455 1509.43 M479.228 1505.36 L485.108 1505.36 L485.108 1527.88 L490.038 1527.88 L490.038 1531.77 L485.108 1531.77 L485.108 1539.92 L480.455 1539.92 L480.455 1531.77 L464.853 1531.77 L464.853 1527.26 L479.228 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M855.986 1525.04 L868.463 1525.04 L868.463 1528.83 L855.986 1528.83 L855.986 1525.04 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M877.56 1535.98 L893.879 1535.98 L893.879 1539.92 L871.935 1539.92 L871.935 1535.98 Q874.597 1533.23 879.18 1528.6 Q883.787 1523.95 884.967 1522.61 Q887.213 1520.08 888.092 1518.35 Q888.995 1516.59 888.995 1514.9 Q888.995 1512.14 887.051 1510.41 Q885.129 1508.67 882.028 1508.67 Q879.829 1508.67 877.375 1509.43 Q874.944 1510.2 872.167 1511.75 L872.167 1507.03 Q874.991 1505.89 877.444 1505.31 Q879.898 1504.73 881.935 1504.73 Q887.305 1504.73 890.5 1507.42 Q893.694 1510.11 893.694 1514.6 Q893.694 1516.73 892.884 1518.65 Q892.097 1520.54 889.991 1523.14 Q889.412 1523.81 886.31 1527.03 Q883.208 1530.22 877.56 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M1279.82 1508.44 Q1276.2 1508.44 1274.38 1512 Q1272.57 1515.55 1272.57 1522.67 Q1272.57 1529.78 1274.38 1533.35 Q1276.2 1536.89 1279.82 1536.89 Q1283.45 1536.89 1285.26 1533.35 Q1287.08 1529.78 1287.08 1522.67 Q1287.08 1515.55 1285.26 1512 Q1283.45 1508.44 1279.82 1508.44 M1279.82 1504.73 Q1285.63 1504.73 1288.68 1509.34 Q1291.76 1513.92 1291.76 1522.67 Q1291.76 1531.4 1288.68 1536.01 Q1285.63 1540.59 1279.82 1540.59 Q1274.01 1540.59 1270.93 1536.01 Q1267.87 1531.4 1267.87 1522.67 Q1267.87 1513.92 1270.93 1509.34 Q1274.01 1504.73 1279.82 1504.73 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M1679.35 1535.98 L1695.67 1535.98 L1695.67 1539.92 L1673.73 1539.92 L1673.73 1535.98 Q1676.39 1533.23 1680.97 1528.6 Q1685.58 1523.95 1686.76 1522.61 Q1689 1520.08 1689.88 1518.35 Q1690.79 1516.59 1690.79 1514.9 Q1690.79 1512.14 1688.84 1510.41 Q1686.92 1508.67 1683.82 1508.67 Q1681.62 1508.67 1679.17 1509.43 Q1676.74 1510.2 1673.96 1511.75 L1673.96 1507.03 Q1676.78 1505.89 1679.24 1505.31 Q1681.69 1504.73 1683.73 1504.73 Q1689.1 1504.73 1692.29 1507.42 Q1695.49 1510.11 1695.49 1514.6 Q1695.49 1516.73 1694.68 1518.65 Q1693.89 1520.54 1691.78 1523.14 Q1691.2 1523.81 1688.1 1527.03 Q1685 1530.22 1679.35 1535.98 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M2092.59 1509.43 L2080.79 1527.88 L2092.59 1527.88 L2092.59 1509.43 M2091.36 1505.36 L2097.24 1505.36 L2097.24 1527.88 L2102.17 1527.88 L2102.17 1531.77 L2097.24 1531.77 L2097.24 1539.92 L2092.59 1539.92 L2092.59 1531.77 L2076.99 1531.77 L2076.99 1527.26 L2091.36 1505.36 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M62.9921 1406.4 L75.4689 1406.4 L75.4689 1410.2 L62.9921 1410.2 L62.9921 1406.4 Z\" fill=\"#000000\" fill-rule=\"evenodd\" fill-opacity=\"1\" /><path clip-path=\"url(#clip6800)\" d=\"M 0 0 M94.7049 1402.65 Q98.0614 1403.37 99.9364 1405.64 Q101.835 1407.9 101.835 1411.24 Q101.835 1416.35 98.316 1419.15 Q94.7975 1421.95 88.3161 1421.95 Q86.1402 1421.95 83.8253 1421.51 Q81.5337 1421.1 79.08 1420.24 L79.08 1415.73 Q81.0244 1416.86 83.3392 1417.44 Q85.654 1418.02 88.1772 1418.02 Q92.5753 1418.02 94.867 1416.28 Q97.1818 1414.55 97.1818 1411.24 Q97.1818 1408.18 95.029 1406.47 Q92.8994 1404.73 89.0799 1404.73 L85.0522 1404.73 L85.0522 1400.89 L89.2651 1400.89 Q92.7142 1400.89 94.5429 1399.52 Q96.3716 1398.14 96.3716 1395.54 Q96.3716 1392.88 94.4734 1391.47 Q92.5984 1390.03
2020-05-22 16:18:56 +00:00
" 267.608,1445.72 470.05,998.35 672.491,830.457 874.933,784.365 1077.37,777.483 1279.82,777.274 1482.26,776.231 1684.7,766.846 1887.14,716.583 2089.58,542.85 \n",
" 2292.02,87.9763 \n",
" \"/>\n",
"</svg>\n"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using Plots\n",
"gr()\n",
"\n",
"functionvalues = Array{Int64,2}(undef,11,2)\n",
"index = 1\n",
"for x = -5:5\n",
" functionvalues[index,1] = x\n",
" functionvalues[index,2] = y(x)\n",
" index = index + 1\n",
"end\n",
"\n",
"plot(functionvalues[:,1],functionvalues[:,2],label=false)"
]
},
{
"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
}