{ "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": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\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 }