{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"execution_count": 2,
"metadata": {
},
"output_type": "execute_result"
},
{
"data": {
"text/html": [
""
]
},
"execution_count": 2,
"metadata": {
},
"output_type": "execute_result"
}
],
"source": [
"#1) prove: 1 + 2 + 3 + ... + n = n(n+1)/2\n",
"f(n) = n*(1 + n)/2\n",
"show(f(1))\n",
"show(f(2))\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"execution_count": 3,
"metadata": {
},
"output_type": "execute_result"
},
{
"data": {
"text/html": [
""
]
},
"execution_count": 3,
"metadata": {
},
"output_type": "execute_result"
}
],
"source": [
"# prove: 1 + 2 + 3 + ... + n + (n + 1) = (n + 1)(n + 2)/2\n",
"# assume: 1 + 2 + 3 + ... + n = n(1 + n)/2\n",
"# show: n + 1 = (n + 1)(n + 2)/2 - n(1 + n)/2\n",
"show((n + 1)*(n + 2)/2 - n*(1 + n)/2)\n",
"show(((n + 1)*(n + 2)/2 - n*(1 + n)/2).expand())\n",
"# other than expand(), we might also have used\n",
"# simplify_rational(), simplify_radical(), or simplify_trig()\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
],
"source": [
"def symbolic_inverse(f, x):\n",
" y = SR.var('y')\n",
" g = (f - y).roots(x, multiplicities=False)\n",
" return [expr.subs(y=x) for expr in g]\n",
"\n",
"def convert_to_mixed(n, d):\n",
" m, p = divmod(abs(n), d)\n",
" if n < Integer(Integer(0)):\n",
" m = -m\n",
" g = gcd(p, d)\n",
" p = p/g\n",
" d = d/g\n",
" return '{} {}/{}'.format(m, p, d) if m != Integer(Integer(0)) and p > Integer(Integer(0)) else '{}'.format(m) if m != Integer(Integer(0)) else '{}/{}'.format(n, d)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'16 7/8'"
]
},
"execution_count": 5,
"metadata": {
},
"output_type": "execute_result"
}
],
"source": [
"convert_to_mixed(270, 16)\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"execution_count": 6,
"metadata": {
},
"output_type": "execute_result"
}
],
"source": [
"%display typeset\n",
"symbolic_inverse(5*x - 3, x)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"execution_count": 7,
"metadata": {
},
"output_type": "execute_result"
}
],
"source": [
"symbolic_inverse(x^2, x)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"execution_count": 8,
"metadata": {
},
"output_type": "execute_result"
}
],
"source": [
"symbolic_inverse(log(x), x)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# Modern Algebra: A Logical Approach, Book Two c.1966\n",
"\n",
"## Chapter 6: Functions and Other Relations\n",
"## Linear Inequalities\n",
"## ----------------------------------------------------------------------------------\n",
"\n",
"(1) Draw the graph of the relation defined by each of the following sentences.\n",
"\n",
"(a) y > -2*x + 3 $\\lor$ y < x"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "c1fcc23ecbc2f7c63f8901f309ff72db902c1eb3"
}
}
],
"source": [
"x, y = var('x y')\n",
"p = region_plot(y > -2*x + 3, (x, -200, 200), (y, -200, 200))\n",
"p += region_plot(y < x, (x, -200, 200), (y, -200, 200))\n",
"show(p)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"y > -2*x + 3 $\\land$ y < x"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "13ce891c538d683bd752bcfb7f7f53abb567add1"
}
}
],
"source": [
"q = region_plot([y > -2*x + 3, y < x], (x, -50, 150), (y, -300, 300))\n",
"show(q)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"Let's experiment a little. The objective here is to learn about linear inequalities while also gaining some technical skills using Sage. This is explortative learning at age 50."
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# ------------------------------\n",
"y > -2*x + 3 $\\lor$ y < x"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "6457f90a290957350150ecd522293fbf9c97c4b6"
}
}
],
"source": [
"p = region_plot( y > -2*x + 3, (x, -100, 100), (y, -100, 100), incol='orange')\n",
"p += region_plot(y < x, (x, -100, 100), (y, -100, 100),incol='cyan')\n",
"show(p, axes=\"true\", frame=False, aspect_ratio=1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# ------------------------------\n",
"y $\\le$ 7 $\\lor$ y $\\ge$ -3"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "dbbc2601a682a1184a55cf70abd90a8a8bb76c9a"
}
}
],
"source": [
"p1 = region_plot(y <= 7, (x, -100, 100), (y, -100, 100), incol='red')\n",
"p1 += region_plot(y >= -3, (x, -100, 100), (y, -100, 100), incol='blue')\n",
"show(p1, axes=\"true\", frame=False, aspect_ratio=1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# ------------------------------\n",
"y $\\lt$ 3 $\\lor$ y $\\ge$ x + 6 $\\lor$ y $\\lt$ -x - 3"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "db712f58e4d38712dd322093f53771cdb91e07db"
}
}
],
"source": [
"p2 = region_plot(y < 3, (x, -10, 10), (y, -10, 10), incol='red')\n",
"p2 += region_plot(y > x + 6, (x, -10, 10), (y, -10, 10), incol='blue')\n",
"p2 += region_plot(y < -x - 3, (x, -10, 10), (y, -10, 10), incol='green')\n",
"show(p2, axes=\"true\", frame=False, aspect_ratio=1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# ------------------------------\n",
"3*x + y $\\gt$ 5 $\\lor$ -2*x + y $\\lt$ -4"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "8c41cc77b668eb8ac4f7c53f4dba7b8c8e216b69"
}
}
],
"source": [
"p3 = region_plot(3*x + y > 5, (x, -10, 10), (y, -10, 10), incol='orange')\n",
"p3 += region_plot(-2*x + y < -4, (x, -10, 10), (y, -10, 10), incol='purple')\n",
"show(p3, axes=\"true\", frame=False, aspect_ratio=1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# ------------------------------\n",
"y $\\gt$ x $\\lor$ y $\\lt$ 4"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "4037dcb61c47f8392904df8d8f69fac2b68dc164"
}
}
],
"source": [
"p3 = region_plot(y > x, (x, -10, 10), (y, -10, 10), incol='cyan')\n",
"p3 += region_plot(y < 4, (x, -10, 10), (y, -10, 10), incol='brown')\n",
"show(p3, axes=\"true\", frame=False, aspect_ratio=1)\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "acaa1e2f3ecf3157c8eaf83d2982cbd2ee62b51b"
}
}
],
"source": [
"p4 = region_plot([2 <= y, y <= 3], (x, -10, 10), (y, -10, 10))\n",
"show(p4)\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "2dc70d3e9c5dd7a5da37a86db76d7395a352884e"
}
}
],
"source": [
"p5 = region_plot([2*x + 5 >= y or y >= -4*x + 1], (x, -10, 10), (y, -10, 10))\n",
"show(p5)\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "1508eac221be40f9112f9ef13b606fe49a9236fe"
}
}
],
"source": [
"p6 = region_plot([x - 2 <= y, y <= x + 2], (x, -10, 10), (y, -10, 10))\n",
"show(p6)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------------------------------------\n",
"\n",
"[2] Draw the graph of the relation defined by each of the following sentences\n",
"\n",
"(a) y > -2*x - 5 $\\land$ y > -3*x + 4"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "7c57fd787addf4aa932a90c1393cd839c978836b"
}
}
],
"source": [
"p = region_plot([y > -2*x - 5,y > -3*x + 4], (x, -10, 10), (y, -10, 10))\n",
"show(p)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"Changing this from a conjunction (intersection) to a disjunction (union):\n",
"\n",
"(a) y > -2*x - 5 $\\lor$ y > -3*x + 4"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "f67162501215423325857a12e602852e151887de"
}
}
],
"source": [
"p1 = region_plot(y > -2*x - 5, (x, -10, 10), (y, -10, 10), incol='orange')\n",
"p2 = region_plot(y > -3*x + 4, (x, -10, 10), (y, -10, 10), incol='purple')\n",
"show(p1 + p2, axes=\"true\", frame=False, aspect_ratio=1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------------------------------------\n",
"\n",
"(b) 3*x + 1 > y $\\land$ y > -4*x - 3"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "e8af69397652cd7b812dfb9230094b451807a625"
}
}
],
"source": [
"p = region_plot([3*x + 1 > y,y > -4*x - 3], (x, -10, 10), (y, -10, 10))\n",
"show(p)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"Changing this from a conjunction (intersection) to a disjunction (union):\n",
"\n",
"(b) 3*x + 1 > y $\\lor$ y > -4*x - 3"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "1ff8665f8d95fa50379d7d6812b6aaa8a7410683"
}
}
],
"source": [
"p1 = region_plot(3*x + 1 > y, (x, -10, 10), (y, -10, 10), incol='orange')\n",
"p2 = region_plot(y > -4*x - 3, (x, -10, 10), (y, -10, 10), incol='purple')\n",
"show(p1 + p2, axes=\"true\", frame=False, aspect_ratio=1)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------------------------------------\n",
"\n",
"(c) x >= 0 and y >= 0 $\\land$ y <= x + 4"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "fc7216720f25ff1e28bac6bc2abe70a162a98298"
}
}
],
"source": [
"p = region_plot([x >= 0, y >= 0, y <= x + 4], (x, -10, 25), (y, -10, 25), incol='red')\n",
"show(p)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------------------------------------\n",
"\n",
"(d) y <= x + 4 $\\land$ y > -x - 2 and x > 0"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "8feaa84c29e1568e816a385a101920d5004c9013"
}
}
],
"source": [
"p = region_plot([y <= x + 4, y > -x - 2, x > 0], (x, -10, 30), (y, -40, 40), incol='yellow')\n",
"show(p)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------------------------------------\n",
"\n",
"(e) y <= 4 $\\land$ x <= 3 $\\land$ y > -3 $\\land$ x > -3"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "7cf4d9848140c3e07944873e63d0afc893039557"
}
}
],
"source": [
"p = region_plot([y <= 4, x <= 3, y > -3, x > -3], (x, -5, 5), (y, -5, 5), incol='green')\n",
"show(p)\n"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "1a2e156a64aef0acd2e5c753bb898f0fefd256a6"
}
}
],
"source": [
"# p.316 (4) \n",
"# To confirm my \"pencil and paper\" results: No graph\n",
"p = region_plot([y < 4, y > -4, x >= 4, x > -4, y <= -x + 5, y >= x - 5, y >= -x + 5, y < x + 5], (x, -5, 10), (y, -5, 5))\n",
"show(p)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"(5) Given:\n",
" A = {(x,y)| y <= -5*x/3 + 7}, \n",
" B = {(x,y)| y >= x - 1}, \n",
" C = ((x,y)| y <= 9*x + 39}, \n",
" D = {(x,y)| y >= -7*x + 25}, \n",
" \n",
"draw the graph of:"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"(a) \n",
"A $\\cap$ B $\\cap$ C"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "798e4f95a61d0d15bba4bf2a1ee2da47cd098d50"
}
}
],
"source": [
"A = y <= -5*x/3 + 7\n",
"B = y >= x - 1\n",
"C = y <= 9*x + 39\n",
"D = y >= -7*x + 25\n",
"# (a)\n",
"p = region_plot([A, B, C], (x, -10, 10), (y, -10, 15))\n",
"show(p)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------\n",
"\n",
"(b) \n",
"A $\\cap$ B $\\cap$ C $\\cap$ D"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "a2d5ef07220f6ca2c0613461339bd210120ea23d"
}
}
],
"source": [
"p = region_plot([A, B, C, D], (x, -10, 10), (y, -10, 15))\n",
"show(p)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------------------------------\n",
"\n",
"(6) If M = x - y, find the greatest possible value of M subject to the condition that (x,y) are coordinates of a point in A, the region which is the graph of {(x,y)| y <= -2*x/5 + 4} $\\cap$ {(x,y)| y >= x - 3} $\\cap$ {(x,y)| y >= 0} $\\cap$ {(x,y)| x >= 0}"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "bf2cd36da065811fb538ceaae81043da1e67b0d1"
}
}
],
"source": [
"A = region_plot([y <= -2*x/5 + 4, y >= x - 3, y >= 0, x >= 0], (x, -5, 5), (y, -5, 5) )\n",
"show(A)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"If M = x - y, the greatest possible value of M, subject to the condition \n",
"that (x,y) are coordinates of a point in A, the region which is the graph of\n",
"{(x,y)| y <= -2*x/5 + 4} intersection {(x,y)| y >= x - 3} \n",
"intersection {(x,y)| y >= 0} intersection {(x,y)| x >= 0} is ...\n",
"M = 3\n"
]
}
],
"source": [
"M(x,y) = x - y\n",
"M_vals = []\n",
"for X in range(4):\n",
" for Y in range(5):\n",
" if Y <= -2*X/5 + 4 and Y >= X - 3 and Y >= 0 and Y >= 0:\n",
" M_vals.append(M(X,Y))\n",
"print('If M = x - y, the greatest possible value of M, subject to the condition ')\n",
"print('that (x,y) are coordinates of a point in A, the region which is the graph of')\n",
"print('{(x,y)| y <= -2*x/5 + 4} intersection {(x,y)| y >= x - 3} ')\n",
"print('intersection {(x,y)| y >= 0} intersection {(x,y)| x >= 0} is ...')\n",
"print('M = {}'.format(max(M_vals)))"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"# --------------------------------------------------------------------------------- \n",
"\n",
"(7) If K = -x/3 + y, find the least possible value of K subject to the condition that \n",
"(x,y) are the coordinates of a point in B, the region which is the graph of \n",
"{(x,y)| y >= -2*x + 8} $\\cap$ {(x,y)| y >= 2*x/3}"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "cd6a4efe1b63efb7b99ce96e0743d9b35d4c471d"
}
}
],
"source": [
"B = region_plot([y >= -2*x + 8, y >= 2*x/3], (x, -5, 10), (y, -5, 10) )\n",
"show(B)"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"collapsed": false
},
"outputs": [
],
"source": [
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x = 2 and y = 4 so K = 10/3\n",
"x = 3 and y = 2 so K = 1\n",
"x = 3 and y = 3 so K = 2\n",
"x = 3 and y = 4 so K = 3\n",
"x = 4 and y = 3 so K = 5/3\n",
"x = 4 and y = 4 so K = 8/3\n",
"If K = -x/3 + y, the least possible value of K subject to the condition that\n",
"(x,y) are the coordinates of a point in B, the region which is the graph of\n",
"{(x,y)| y >= -2*x + 8} intersection {(x,y)| y >= 2*x/3} ...\n",
"is K = 1 \n"
]
}
],
"source": [
"K(x,y) = -x/3 + y\n",
"K_vals = []\n",
"for X in range(5):\n",
" for Y in range(5):\n",
" if Y >= -2*X + 8 and Y >= 2*X/3:\n",
" K_vals.append(K(X,Y))\n",
" print('x = {0} and y = {1} so K = {2}'.format(X, Y, -X/3 + Y))\n",
"print('If K = -x/3 + y, the least possible value of K subject to the condition that')\n",
"print('(x,y) are the coordinates of a point in B, the region which is the graph of')\n",
"print('{(x,y)| y >= -2*x + 8} intersection {(x,y)| y >= 2*x/3} ...')\n",
"print('is K = {:4.3}'.format(min(K_vals)))"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [
],
"source": [
"def frange(x, y, jump=1.0):\n",
" '''\n",
" Range for floats.\n",
"\n",
" Parameters:\n",
" x: range starting value, will be included.\n",
" y: range ending value, will be excluded\n",
" jump: the step value. Only positive steps are supported.\n",
"\n",
" Return:\n",
" a generator that yields floats\n",
"\n",
" Usage:\n",
" >>> list(frange(0, 1, 0.2))\n",
" [0.0, 0.2, 0.4, 0.6000000000000001, 0.8]\n",
" >>> list(frange(1, 0, 0.2))\n",
" [1.0]\n",
" >>> list(frange(0.0, 0.05, 0.1))\n",
" [0.0]\n",
" >>> list(frange(0.0, 0.15, 0.1))\n",
" [0.0, 0.1]\n",
"\n",
" '''\n",
" i = 0.0\n",
" x = float(x) # Prevent yielding integers.\n",
" y = float(y) # Comparison converts y to float every time otherwise.\n",
" x0 = x\n",
" epsilon = jump / 2.0\n",
" yield x # yield always first value\n",
" while x + epsilon < y:\n",
" i += 1.0\n",
" x = x0 + i * jump\n",
" yield x\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x = 1.66666666666667 and y = 5.00000000000000 so K = 4.44444444444444\n",
"x = 2.00000000000000 and y = 4.00000000000000 so K = 3.33333333333333\n",
"x = 2.00000000000000 and y = 4.33333333333333 so K = 3.66666666666667\n",
"x = 2.00000000000000 and y = 4.66666666666667 so K = 4.00000000000000\n",
"x = 2.00000000000000 and y = 5.00000000000000 so K = 4.33333333333333\n",
"x = 2.33333333333333 and y = 3.66666666666667 so K = 2.88888888888889\n",
"x = 2.33333333333333 and y = 4.00000000000000 so K = 3.22222222222222\n",
"x = 2.33333333333333 and y = 4.33333333333333 so K = 3.55555555555555\n",
"x = 2.33333333333333 and y = 4.66666666666667 so K = 3.88888888888889\n",
"x = 2.33333333333333 and y = 5.00000000000000 so K = 4.22222222222222\n",
"x = 2.66666666666667 and y = 3.00000000000000 so K = 2.11111111111111\n",
"x = 2.66666666666667 and y = 3.33333333333333 so K = 2.44444444444444\n",
"x = 2.66666666666667 and y = 3.66666666666667 so K = 2.77777777777778\n",
"x = 2.66666666666667 and y = 4.00000000000000 so K = 3.11111111111111\n",
"x = 2.66666666666667 and y = 4.33333333333333 so K = 3.44444444444444\n",
"x = 2.66666666666667 and y = 4.66666666666667 so K = 3.77777777777778\n",
"x = 2.66666666666667 and y = 5.00000000000000 so K = 4.11111111111111\n",
"x = 3.00000000000000 and y = 2.00000000000000 so K = 1.00000000000000\n",
"x = 3.00000000000000 and y = 2.33333333333333 so K = 1.33333333333333\n",
"x = 3.00000000000000 and y = 2.66666666666667 so K = 1.66666666666667\n",
"x = 3.00000000000000 and y = 3.00000000000000 so K = 2.00000000000000\n",
"x = 3.00000000000000 and y = 3.33333333333333 so K = 2.33333333333333\n",
"x = 3.00000000000000 and y = 3.66666666666667 so K = 2.66666666666667\n",
"x = 3.00000000000000 and y = 4.00000000000000 so K = 3.00000000000000\n",
"x = 3.00000000000000 and y = 4.33333333333333 so K = 3.33333333333333\n",
"x = 3.00000000000000 and y = 4.66666666666667 so K = 3.66666666666667\n",
"x = 3.00000000000000 and y = 5.00000000000000 so K = 4.00000000000000\n",
"x = 3.33333333333333 and y = 2.33333333333333 so K = 1.22222222222222\n",
"x = 3.33333333333333 and y = 2.66666666666667 so K = 1.55555555555556\n",
"x = 3.33333333333333 and y = 3.00000000000000 so K = 1.88888888888889\n",
"x = 3.33333333333333 and y = 3.33333333333333 so K = 2.22222222222222\n",
"x = 3.33333333333333 and y = 3.66666666666667 so K = 2.55555555555556\n",
"x = 3.33333333333333 and y = 4.00000000000000 so K = 2.88888888888889\n",
"x = 3.33333333333333 and y = 4.33333333333333 so K = 3.22222222222222\n",
"x = 3.33333333333333 and y = 4.66666666666667 so K = 3.55555555555556\n",
"x = 3.33333333333333 and y = 5.00000000000000 so K = 3.88888888888889\n",
"x = 3.66666666666667 and y = 2.66666666666667 so K = 1.44444444444444\n",
"x = 3.66666666666667 and y = 3.00000000000000 so K = 1.77777777777778\n",
"x = 3.66666666666667 and y = 3.33333333333333 so K = 2.11111111111111\n",
"x = 3.66666666666667 and y = 3.66666666666667 so K = 2.44444444444444\n",
"x = 3.66666666666667 and y = 4.00000000000000 so K = 2.77777777777778\n",
"x = 3.66666666666667 and y = 4.33333333333333 so K = 3.11111111111111\n",
"x = 3.66666666666667 and y = 4.66666666666667 so K = 3.44444444444444\n",
"x = 3.66666666666667 and y = 5.00000000000000 so K = 3.77777777777778\n",
"x = 4.00000000000000 and y = 3.00000000000000 so K = 1.66666666666667\n",
"x = 4.00000000000000 and y = 3.33333333333333 so K = 2.00000000000000\n",
"x = 4.00000000000000 and y = 3.66666666666667 so K = 2.33333333333333\n",
"x = 4.00000000000000 and y = 4.00000000000000 so K = 2.66666666666667\n",
"x = 4.00000000000000 and y = 4.33333333333333 so K = 3.00000000000000\n",
"x = 4.00000000000000 and y = 4.66666666666667 so K = 3.33333333333333\n",
"x = 4.00000000000000 and y = 5.00000000000000 so K = 3.66666666666667\n",
"x = 4.33333333333333 and y = 3.00000000000000 so K = 1.55555555555556\n",
"x = 4.33333333333333 and y = 3.33333333333333 so K = 1.88888888888889\n",
"x = 4.33333333333333 and y = 3.66666666666667 so K = 2.22222222222222\n",
"x = 4.33333333333333 and y = 4.00000000000000 so K = 2.55555555555556\n",
"x = 4.33333333333333 and y = 4.33333333333333 so K = 2.88888888888889\n",
"x = 4.33333333333333 and y = 4.66666666666667 so K = 3.22222222222222\n",
"x = 4.33333333333333 and y = 5.00000000000000 so K = 3.55555555555556\n",
"x = 4.66666666666667 and y = 3.33333333333333 so K = 1.77777777777778\n",
"x = 4.66666666666667 and y = 3.66666666666667 so K = 2.11111111111111\n",
"x = 4.66666666666667 and y = 4.00000000000000 so K = 2.44444444444444\n",
"x = 4.66666666666667 and y = 4.33333333333333 so K = 2.77777777777778\n",
"x = 4.66666666666667 and y = 4.66666666666667 so K = 3.11111111111111\n",
"x = 4.66666666666667 and y = 5.00000000000000 so K = 3.44444444444444\n",
"x = 5.00000000000000 and y = 3.66666666666667 so K = 2.00000000000000\n",
"x = 5.00000000000000 and y = 4.00000000000000 so K = 2.33333333333333\n",
"x = 5.00000000000000 and y = 4.33333333333333 so K = 2.66666666666667\n",
"x = 5.00000000000000 and y = 4.66666666666667 so K = 3.00000000000000\n",
"x = 5.00000000000000 and y = 5.00000000000000 so K = 3.33333333333333\n",
"If K = -x/3 + y, the least possible value of K subject to the condition that\n",
"(x,y) are the coordinates of a point in B, the region which is the graph of\n",
"{(x,y)| y >= -2*x + 8} intersection {(x,y)| y >= 2*x/3} ...\n",
"is K = 1.0 \n"
]
}
],
"source": [
"K(x,y) = -x/3 + y\n",
"K_vals = []\n",
"for X in frange(-5, 5, 1/3):\n",
" for Y in frange(-5, 5, 1/3):\n",
" if Y >= -2*X + 8 and Y >= 2*X/3:\n",
" K_vals.append(K(X,Y))\n",
" print('x = {0} and y = {1} so K = {2}'.format(X, Y, -X/3 + Y))\n",
"print('If K = -x/3 + y, the least possible value of K subject to the condition that')\n",
"print('(x,y) are the coordinates of a point in B, the region which is the graph of')\n",
"print('{(x,y)| y >= -2*x + 8} intersection {(x,y)| y >= 2*x/3} ...')\n",
"print('is K = {:4.3}'.format(min(K_vals)))"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"collapsed": false
},
"outputs": [
],
"source": [
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"collapsed": false
},
"outputs": [
],
"source": [
]
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath (stable)",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.14"
}
},
"nbformat": 4,
"nbformat_minor": 0
}