├── GWU_Logo_Horizontal.png ├── README.md ├── Lecture06Equations.ipynb ├── Lecture07QuadraticEquations.ipynb ├── Lecture04OrderingAndDistribution.ipynb └── Lecture05Factoring.ipynb /GWU_Logo_Horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/juanklopper/AlgebraPublicHealthDataScience/main/GWU_Logo_Horizontal.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Algebra for Public Health Data Science 2 | 3 | GitHub repo for algebra courseware 4 | 5 | Read more HERE 6 | 7 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/juanklopper/AlgebraPublicHealthBiomedicine/HEAD) 8 | -------------------------------------------------------------------------------- /Lecture06Equations.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 6 | EQUATIONS" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | ">Dr J H Klopper

\n", 15 | ">Department of Biostatistics and Bioinformatics
\n", 16 | ">Milken Institute School of Public Health
\n", 17 | ">George Washington University" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "

This chapter of Algebra for Health Data Science by Dr JH Klopper is licensed under Attribution-NonCommercial-NoDerivatives 4.0 International

" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "- Watch the pencil and paper video lecture [HERE](https://youtu.be/m3fzIwiDD-Q)\n", 32 | "\n", 33 | "- Watch the Python video lecture [HERE](https://youtu.be/yDI8LrhZ6Vs)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "## 6.1 Packages used in this chapter" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "As in the previous chapter, we only import the function from the `sympy` package that we will use in this chapter." 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 1, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "from sympy import init_printing, symbols, Eq, solve, Rational" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "The `init_printing` function is used to display the output of `sympy` code in mathematical notation." 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 2, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "init_printing()" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## 6.2 Introduction" 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": {}, 85 | "source": [ 86 | "In this chapter we explore equations and how to solve them. Solving involves isolating the unknown variable on one side of the equation." 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "Formulas are typical examples of equations. We use formulas in health data science to calculate values of interest. At the end of this chapter we explore the concept of confidence intervals and how to manipulate the formula to find any value of interest." 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "## 6.3 Equations and their rules" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "__Definition 6.3.1__ An __equation__ is a statement that consider two equal expressions. The expressions are called the left-hand side (LHS) and the right-hand side (RHS) of the equation. The LHS and RHS are separated by an equal sign, indicating the equality." 108 | ] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "metadata": {}, 113 | "source": [ 114 | "We see a very simple example of an equation in __Equation 6.3.1__." 115 | ] 116 | }, 117 | { 118 | "cell_type": "markdown", 119 | "metadata": {}, 120 | "source": [ 121 | "$$\n", 122 | "x = 2\n", 123 | "\\tag{Equation 6.3.1}\n", 124 | "$$" 125 | ] 126 | }, 127 | { 128 | "cell_type": "markdown", 129 | "metadata": {}, 130 | "source": [ 131 | "It is very clear that the only value that $x$ can take is $2$. This is because the LHS and RHS are equal. We can see that the equation is true for $2 = 2$." 132 | ] 133 | }, 134 | { 135 | "cell_type": "markdown", 136 | "metadata": {}, 137 | "source": [ 138 | "In __Equation 6.3.2__ we see a more complicated equation." 139 | ] 140 | }, 141 | { 142 | "cell_type": "markdown", 143 | "metadata": {}, 144 | "source": [ 145 | "$$\n", 146 | "x + 1 = 2\n", 147 | "\\tag{Equation 6.3.2}\n", 148 | "$$" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "metadata": {}, 154 | "source": [ 155 | "The aim of a single variable equation such as __Equation 6.3.2__ is to find the value of $x$ that makes the equation true. We need to _isolate_ the variable $x$ on one side of the equation, which is usually the LHS. To maintain equality between the LHS and the RHS of an equation, we must make the same changes on both sides of the equation. In the case of __Equation 6.3.2__ we can subtract $1$ from both sides of the equation. This gives us __Equation 6.3.3__." 156 | ] 157 | }, 158 | { 159 | "cell_type": "markdown", 160 | "metadata": {}, 161 | "source": [ 162 | "$$\n", 163 | "\\begin{align*}\n", 164 | "&\\left( x + 1 \\right) = \\left( 2 \\right) \\text{ or (LHS) = (RHS)} \\\\ \\\\\n", 165 | "&\\left( x + 1 \\right) \\mathbf{- 1} = \\left( 2 \\right) \\mathbf{- 1} \\text{ (subtract } 1 \\text{ from both sides)} \\\\ \\\\ \n", 166 | "\\end{align*}\n", 167 | "\\tag{Equation 6.3.3}\n", 168 | "$$" 169 | ] 170 | }, 171 | { 172 | "cell_type": "markdown", 173 | "metadata": {}, 174 | "source": [ 175 | "Performing the arithmetic on both sides of the equation gives us __Equation 6.3.4__ and a solution to our equation." 176 | ] 177 | }, 178 | { 179 | "cell_type": "markdown", 180 | "metadata": {}, 181 | "source": [ 182 | "$$\n", 183 | "\\begin{align*}\n", 184 | "&x + 1 - 1 = 2 - 1 \\\\ \\\\\n", 185 | "&x = 1\n", 186 | "\\end{align*}\n", 187 | "\\tag{Equation 6.3.4}\n", 188 | "$$" 189 | ] 190 | }, 191 | { 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "__Homework 6.3.1__ Solve the equation $x - 3 = 5$." 196 | ] 197 | }, 198 | { 199 | "cell_type": "markdown", 200 | "metadata": {}, 201 | "source": [ 202 | "This solves the original equation since $1 + 1 = 2$ (where we substitute $x = 1$ into the original equation)." 203 | ] 204 | }, 205 | { 206 | "cell_type": "markdown", 207 | "metadata": {}, 208 | "source": [ 209 | "While we can add or subtract on both sides of the equation, we can also divide. We must make sure, though, to divide all terms on each side. Such an example is shown in __Equation 6.3.5__." 210 | ] 211 | }, 212 | { 213 | "cell_type": "markdown", 214 | "metadata": {}, 215 | "source": [ 216 | "$$\n", 217 | "2x = 4\n", 218 | "\\tag{Equation 6.3.5}\n", 219 | "$$" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "metadata": {}, 225 | "source": [ 226 | "We can divide both sides of the equation by $2$ to give us __Equation 6.3.6__." 227 | ] 228 | }, 229 | { 230 | "cell_type": "markdown", 231 | "metadata": {}, 232 | "source": [ 233 | "$$\n", 234 | "\\frac{2x}{\\mathbf{2}} = \\frac{4}{\\mathbf{2}}\n", 235 | "\\tag{Equation 6.3.6}\n", 236 | "$$" 237 | ] 238 | }, 239 | { 240 | "cell_type": "markdown", 241 | "metadata": {}, 242 | "source": [ 243 | "Now we need only perform the arithmetic on both sides of the equation to give us __Equation 6.3.7__." 244 | ] 245 | }, 246 | { 247 | "cell_type": "markdown", 248 | "metadata": {}, 249 | "source": [ 250 | "$$\n", 251 | "x = 2\n", 252 | "\\tag{Equation 6.3.7}\n", 253 | "$$" 254 | ] 255 | }, 256 | { 257 | "cell_type": "markdown", 258 | "metadata": {}, 259 | "source": [ 260 | "Note that we could also have multiplied both sides of the equation by a half to give us the same result. This is shown in __Equation 6.3.8__." 261 | ] 262 | }, 263 | { 264 | "cell_type": "markdown", 265 | "metadata": {}, 266 | "source": [ 267 | "$$\n", 268 | "\\begin{align*}\n", 269 | "&\\mathbf{\\frac{1}{2}} \\times 2x = \\mathbf{\\frac{1}{2}} \\times 4 \\\\ \\\\\n", 270 | "&\\frac{2}{2} \\times x = \\frac{4}{2} \\\\ \\\\\n", 271 | "&x=2\n", 272 | "\\end{align*}\n", 273 | "\\tag{Equation 6.3.8}\n", 274 | "$$" 275 | ] 276 | }, 277 | { 278 | "cell_type": "markdown", 279 | "metadata": {}, 280 | "source": [ 281 | "We can perform more complicated operations on both sides of the equation. We see an example of an equation with a square in __Equation 6.3.9__." 282 | ] 283 | }, 284 | { 285 | "cell_type": "markdown", 286 | "metadata": {}, 287 | "source": [ 288 | "$$\n", 289 | "x^{2} = 4\n", 290 | "\\tag{Equation 6.3.9}\n", 291 | "$$" 292 | ] 293 | }, 294 | { 295 | "cell_type": "markdown", 296 | "metadata": {}, 297 | "source": [ 298 | "In this case, we can take the square root of both sides of the equation. This gives us __Equation 6.3.10__." 299 | ] 300 | }, 301 | { 302 | "cell_type": "markdown", 303 | "metadata": {}, 304 | "source": [ 305 | "$$\n", 306 | "\\begin{align*}\n", 307 | "&\\sqrt{x^{2}} = \\sqrt{4} \\\\ \\\\\n", 308 | "&x = \\pm 2\n", 309 | "\\end{align*}\n", 310 | "\\tag{Equation 6.3.10}\n", 311 | "$$" 312 | ] 313 | }, 314 | { 315 | "cell_type": "markdown", 316 | "metadata": {}, 317 | "source": [ 318 | "We confirm the result by substituting $2$ and then $-2$ into __Equation 6.3.9__ and then noting that $2 \\times 2 = 4$ and $(-2) \\times (-2) = 4$. Both $2$ and $-2$ are solutions to the equation." 319 | ] 320 | }, 321 | { 322 | "cell_type": "markdown", 323 | "metadata": {}, 324 | "source": [ 325 | "__Homework 6.3.2__ Solve the equation $x^{2} = 9$." 326 | ] 327 | }, 328 | { 329 | "cell_type": "markdown", 330 | "metadata": {}, 331 | "source": [ 332 | "## 6.3 Solving equations using `sympy`" 333 | ] 334 | }, 335 | { 336 | "cell_type": "markdown", 337 | "metadata": {}, 338 | "source": [ 339 | "We have seen that _solving_ an equation means finding the value of the variable that makes the equation true. That is to say, we want to isolate the variable on one side of the equation. We do this by performing the same operation on both sides of the equation." 340 | ] 341 | }, 342 | { 343 | "cell_type": "markdown", 344 | "metadata": {}, 345 | "source": [ 346 | "__Problem 6.3.1__ Solve the equation in __Equation 6.3.1__." 347 | ] 348 | }, 349 | { 350 | "cell_type": "markdown", 351 | "metadata": {}, 352 | "source": [ 353 | "$$\n", 354 | "2x = 16\n", 355 | "\\tag{Equation 6.3.1}\n", 356 | "$$" 357 | ] 358 | }, 359 | { 360 | "cell_type": "markdown", 361 | "metadata": {}, 362 | "source": [ 363 | "We have seen how to solve the equation using the rules in __Section 6.3__. We can divide both sides of the equation by $2$ to give us __Equation 6.3.2__." 364 | ] 365 | }, 366 | { 367 | "cell_type": "markdown", 368 | "metadata": {}, 369 | "source": [ 370 | "$$\n", 371 | "\\begin{align*}\n", 372 | "&\\frac{2x}{\\mathbf{2}} = \\frac{16}{\\mathbf{2}} \\\\ \\\\\n", 373 | "&x = 8\n", 374 | "\\end{align*}\n", 375 | "\\tag{Equation 6.3.2}\n", 376 | "$$" 377 | ] 378 | }, 379 | { 380 | "cell_type": "markdown", 381 | "metadata": {}, 382 | "source": [ 383 | "In `sympy` we use the `Eq` function to create an equation. We start by defining the variable $x$ as a symbol." 384 | ] 385 | }, 386 | { 387 | "cell_type": "code", 388 | "execution_count": 3, 389 | "metadata": {}, 390 | "outputs": [], 391 | "source": [ 392 | "# Define the symbol x and assign it to the variable x\n", 393 | "x = symbols('x')" 394 | ] 395 | }, 396 | { 397 | "cell_type": "markdown", 398 | "metadata": {}, 399 | "source": [ 400 | "Now we can create the equation using the `Eq` function. We pass the LHS and RHS of the equation as arguments to the function." 401 | ] 402 | }, 403 | { 404 | "cell_type": "code", 405 | "execution_count": 4, 406 | "metadata": {}, 407 | "outputs": [ 408 | { 409 | "data": { 410 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAAAOCAYAAAB5EtGGAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACmklEQVRIDdWX7VEbMRCGBUMBDOkAdwCmA9JBSCogdACTX/Y/BjoAKiC4g7gDAh3gDgJ04DyPRtLojjsYzyRje2f2VlqtzvulV+eN+XwexuPxbgjhDJaG8DN8hv5RxboRfu/h8x28z/i1z3/WLlprt8a8xcOEXCE/Z4Nk/KAOnmb9Kkv83Ma/G9iCWljj6iRsXTNpFj7Gh3QuDzZ5mK0TuBAGdo0Z1mgtCJ9f4SPYWG4/cNq47Iq64CZ15j6Tcgg/YaCyJjdso+/NeG28LmPi+YKvHq/r2mf0nop4WkyKwc9Q2Bld1E5Wl8066ewku6ov3iCmHPVEZDYD6wVsGZug78n+AHkM20nfku4em0kar6oQb2wC49PvP/AAvkMXj9MWkzeUNhhsvpGyzQVrEX+QpygFNhMhYF0xFp/eTUqy88guQo/s6yveIu/RNnf+UL/zZsYv8DE86UwKhgLRBIPLapMdUl9htp/n026RduB6PSrbD97ZAPX2+v+c89s5IXuMG5jC7/6Eb9BP3yQFpRW3vdqV+Y0uonNyfB9pBU1O6LBPZisp6jiygw8MLPxQoC1EYCp3kOWbJS+iK9iSdF+RH119eftKSGKIBcSZLLv82i2dwgaPwgBZOoSxuBKQjcwyFxNsxYIf6Jxr+94Pum4nun8R+peYIpjGuHocmMWk4KhIfIAswJM2mKhr9AYszgi0vjRfa3WyfnTsx7RJ2CwNU5InFqXro1Q48KqebvIwaxr5oebnfmF0J8ytvJWVn5mbID+lC6Fz7b4olj/4lFwQ/BuEr3b3FFkuhRSTcBAvjY3RaPTEpK+dbFv/VJkIX6JtYH4J20VijwBlsspRYr4UwofcARZJn8VBu/kXa43bhrnxaCOZvHN0ETf/AmoVB1JbFCvaAAAAAElFTkSuQmCC", 411 | "text/latex": [ 412 | "$\\displaystyle 2 x = 16$" 413 | ], 414 | "text/plain": [ 415 | "2⋅x = 16" 416 | ] 417 | }, 418 | "execution_count": 4, 419 | "metadata": {}, 420 | "output_type": "execute_result" 421 | } 422 | ], 423 | "source": [ 424 | "# Creating the equation\n", 425 | "Eq(2*x, 16)" 426 | ] 427 | }, 428 | { 429 | "cell_type": "markdown", 430 | "metadata": {}, 431 | "source": [ 432 | "The `solve` function in `sympy` is used to solve equations. We pass the equation as an argument to the function. The second argument states the variable that we wish to solve for. The function returns a list of solutions to the equation." 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "execution_count": 5, 438 | "metadata": {}, 439 | "outputs": [ 440 | { 441 | "data": { 442 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABIAAAAVCAYAAABLy77vAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABWklEQVQ4Ec2U7VECMRCGg2MBjCVgK9IBlKB2IOOvu7+UgJYgHUAHjnYAJSgl+Dzx7ibHJTfqL3dmSfbjfbPZ2zCpquohhHCPKsu6rt+/t+O/5PVwE4jWQHYE9uPQfBRcxF/mwyGQMCX2mMS1X0oHFokArQG1V4582BJN0W1yQNxenDu0SbxjecvEbvGlVXYpWSKi1+i8y/rBpkT0CnZBZX4Ee9OKjd20RrpmewR4q5K4QD/Zr1itUuJBf/CHUkUBwJL4k0mIldygxRkbI7KaE2olztgMPXCA/oFkiUj2q81ZV+gRtfFWqDxjp32LziwREa9iXzoBbG+sThKv2ZMBUXOaQ+e1eoLviEPCq14AI0ckwQnQ7Dy5sa1o8C4HRE2y/YjPobHjArm9cwSsrCelOdqT7HOwsR8J4vePFgJnpv1SCVd+W7paPnvE+/+I2mZv6ImF/+U/25nafQGKdnOorW06AgAAAABJRU5ErkJggg==", 443 | "text/latex": [ 444 | "$\\displaystyle \\left[ 8\\right]$" 445 | ], 446 | "text/plain": [ 447 | "[8]" 448 | ] 449 | }, 450 | "execution_count": 5, 451 | "metadata": {}, 452 | "output_type": "execute_result" 453 | } 454 | ], 455 | "source": [ 456 | "# Solve the equation\n", 457 | "solve(Eq(2*x,16), x)" 458 | ] 459 | }, 460 | { 461 | "cell_type": "markdown", 462 | "metadata": {}, 463 | "source": [ 464 | "There is only a single solution in the list. The value of $8$ confirms our result in __Equation 6.3.2__." 465 | ] 466 | }, 467 | { 468 | "cell_type": "markdown", 469 | "metadata": {}, 470 | "source": [ 471 | "As an alternative, we do not need to pass the equation to the `solve` function. Instead we can algebraically manipulate the equation to have $0$ on the right-hand side. In the case of our example that would be $2x-16=0$. We need only pass the expression that is no $0$ (the left-hand side in this case) to the `solve` function." 472 | ] 473 | }, 474 | { 475 | "cell_type": "code", 476 | "execution_count": 15, 477 | "metadata": {}, 478 | "outputs": [ 479 | { 480 | "data": { 481 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABIAAAAVCAYAAABLy77vAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABWklEQVQ4Ec2U7VECMRCGg2MBjCVgK9IBlKB2IOOvu7+UgJYgHUAHjnYAJSgl+Dzx7ibHJTfqL3dmSfbjfbPZ2zCpquohhHCPKsu6rt+/t+O/5PVwE4jWQHYE9uPQfBRcxF/mwyGQMCX2mMS1X0oHFokArQG1V4582BJN0W1yQNxenDu0SbxjecvEbvGlVXYpWSKi1+i8y/rBpkT0CnZBZX4Ee9OKjd20RrpmewR4q5K4QD/Zr1itUuJBf/CHUkUBwJL4k0mIldygxRkbI7KaE2olztgMPXCA/oFkiUj2q81ZV+gRtfFWqDxjp32LziwREa9iXzoBbG+sThKv2ZMBUXOaQ+e1eoLviEPCq14AI0ckwQnQ7Dy5sa1o8C4HRE2y/YjPobHjArm9cwSsrCelOdqT7HOwsR8J4vePFgJnpv1SCVd+W7paPnvE+/+I2mZv6ImF/+U/25nafQGKdnOorW06AgAAAABJRU5ErkJggg==", 482 | "text/latex": [ 483 | "$\\displaystyle \\left[ 8\\right]$" 484 | ], 485 | "text/plain": [ 486 | "[8]" 487 | ] 488 | }, 489 | "execution_count": 15, 490 | "metadata": {}, 491 | "output_type": "execute_result" 492 | } 493 | ], 494 | "source": [ 495 | "# Solve 2x = 16\n", 496 | "solve(2*x - 16, x)" 497 | ] 498 | }, 499 | { 500 | "cell_type": "markdown", 501 | "metadata": {}, 502 | "source": [ 503 | "__Problem 6.3.2__ You have $99$ participants in a study that has to be divided equally into $3$ groups. How many participants are in each group?" 504 | ] 505 | }, 506 | { 507 | "cell_type": "markdown", 508 | "metadata": {}, 509 | "source": [ 510 | "The problem can be written as an equation, where the unknown is the number of participants in each group and is assigned to the variable $x$. The equation and solution is shown in __Equation 6.3.3__." 511 | ] 512 | }, 513 | { 514 | "cell_type": "markdown", 515 | "metadata": {}, 516 | "source": [ 517 | "$$\n", 518 | "\\begin{align*}\n", 519 | "&3x = 99 \\\\ \\\\\n", 520 | "&\\frac{3x}{\\mathbf{3}} = \\frac{99}{\\mathbf{3}} \\\\ \\\\\n", 521 | "&x = 33\n", 522 | "\\end{align*}\n", 523 | "\\tag{Equation 6.3.3}\n", 524 | "$$" 525 | ] 526 | }, 527 | { 528 | "cell_type": "markdown", 529 | "metadata": {}, 530 | "source": [ 531 | "We use `sympy` to verify the solution." 532 | ] 533 | }, 534 | { 535 | "cell_type": "code", 536 | "execution_count": 6, 537 | "metadata": {}, 538 | "outputs": [ 539 | { 540 | "data": { 541 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAVCAYAAABVAo5cAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABjElEQVRIDd2WMVLDMBBFFeAAwBE4Qgb6FHADcoXkBmSo7DZHCFcIN4gLN3RAB2VaWm4A7xuvRjHSZIvQsDObXUlf/3vXsp1RVVV3IYQ5LpvWdf36kx7mF74d/hGCS6g3LDSHkcizwN/pnOSXQwBwwZpVfkqu8XJ4YV6c6WQFIZHAgmiCgfyWOXVCbX8UAdGFE9bsyJJBnDGeQSgRM2v5vU0Qvbi4pSSog/PZewdGXOOheXFxX6mlquYsokiSalc2z5wLZ3jFUoUpRmLXTOiUzckfdhaTgQeXrdA4IBiTS+wKV/ue8V/mxWnj8WQyuSFuidshE3Mf+BO+btv2i/WG+Mb4PcV6cOzrdFwtFTlV6FHQwVmT63HI2j5cVpBNY3mG0VqqNgcvLuXJCgJ4kUNYrKQn8eKiZunQqHUNgoqpXfYDewl4cZGjJLiIiD5BXG8dVaxHwy7Ei4t0xa8FpLpP04gsv7y9uL1fC7XNWpfo7qZcmAtnu0qHxtYPHv+/oJ3SFfdC7fvL/zTn8G++AQ5hyoARlxjxAAAAAElFTkSuQmCC", 542 | "text/latex": [ 543 | "$\\displaystyle \\left[ 33\\right]$" 544 | ], 545 | "text/plain": [ 546 | "[33]" 547 | ] 548 | }, 549 | "execution_count": 6, 550 | "metadata": {}, 551 | "output_type": "execute_result" 552 | } 553 | ], 554 | "source": [ 555 | "# Solve the equation using sympy\n", 556 | "solve(Eq(3 * x, 99), x)" 557 | ] 558 | }, 559 | { 560 | "cell_type": "markdown", 561 | "metadata": {}, 562 | "source": [ 563 | "As expected, we need $33$ participants in each group." 564 | ] 565 | }, 566 | { 567 | "cell_type": "markdown", 568 | "metadata": {}, 569 | "source": [ 570 | "__Problem 6.3.3__ Solve the equation in __Equation 6.3.4__." 571 | ] 572 | }, 573 | { 574 | "cell_type": "markdown", 575 | "metadata": {}, 576 | "source": [ 577 | "$$\n", 578 | "\\frac{1}{11}x = 33\n", 579 | "\\tag{Equation 6.3.4}\n", 580 | "$$" 581 | ] 582 | }, 583 | { 584 | "cell_type": "markdown", 585 | "metadata": {}, 586 | "source": [ 587 | "The solution is shown in __Equation 6.3.5__, where we multiply both sides by $11$." 588 | ] 589 | }, 590 | { 591 | "cell_type": "markdown", 592 | "metadata": {}, 593 | "source": [ 594 | "$$\n", 595 | "\\begin{align*}\n", 596 | "&\\frac{1}{11}x \\mathbf{\\times 11} = 33 \\mathbf{\\times 11} \\\\ \\\\\n", 597 | "&x = 363\n", 598 | "\\end{align*}\n", 599 | "\\tag{Equation 6.3.5}\n", 600 | "$$" 601 | ] 602 | }, 603 | { 604 | "cell_type": "markdown", 605 | "metadata": {}, 606 | "source": [ 607 | "We verify the result using `sympy`." 608 | ] 609 | }, 610 | { 611 | "cell_type": "code", 612 | "execution_count": 7, 613 | "metadata": {}, 614 | "outputs": [ 615 | { 616 | "data": { 617 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEcAAAAlCAYAAAAQjPROAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACxElEQVRoBe2a7VHbQBCGbcYFGNIBJYSkA+gASAVAB8nwy/5LOkiogAkdQAcQOiAlOO7Aed7LSbOWdB8MH0Y32pnV3d6tzrev9kMnGK9Wq1GI5vP5lLlTP/+Z9gTehb/4sTt0rn2/uGYrYdEFxn8Xo3cHX8L7yN9oBdwFXCxNQpYBgDzGGr9EPoTlPaId2M67wZIuQXAw8h6A/hhj9+g/MCaQRrRHZq7IbjCsMP6hYfEx8lVjrGgxCI61GqD2kZVj6uTL2FRs9Urrd4aVN/oXxioh39KewUv6NszOkZWYi6WQ58hTxAsP1MIiwJjmVL2KpnHXe44HRJXoUdYjq5yrUh3Av2GBVocYcpHUCU7fLeXB7WKDUoFIeVFylSI05iilVxw4GCwwBEQFzoi+vF459Ii+83japF4o5zhke3rRy+upB6QyQUVFdP6/cdekXong6P1s6dmhAFCSm5TU6yzlzVX6JAOEvGTb7tl40Y9qPEevRM+p7HctIOi1Q5X3jP7PtUkjdOlt1HPYkJ6kNv8U0vkuea5D5yOLam19alEI3cMtiukVV61a1jMAAK1qlaM3ns1m4a9dXStkjLGZcYbam6qwp7/8oMr3Nv2uBO32Y/Um79GQ56CGPQqnEa1CyZLCSmEmvs7Rm9i737rPBl8j5+h4I3CiHoJKUm/T4NRvsS/4YBQyt4DTDJ1P/jeqF8Kk3kbBeUFA7FKtzygApYQ8hVXOK9CSekVWKwBQXrHlPnTwjOq1wGFhJTQd0vYMyojrlKu3fle/JBdWGCqX059dFrBiU0i3KFevdWNPBypwFIfODQHgK31XDps2MZel17yvr3LxZ6vnPJgBnAh6AzgDOBEEIlOD5wzgRBCITA2eM4ATQSAyNXjOE8H54PV3IvdpKlcvscz7na4PnhwNdNgU6aSqs5a+pOm/Km6Yq7/a5+pxX+/pH8H2IcECnx82AAAAAElFTkSuQmCC", 618 | "text/latex": [ 619 | "$\\displaystyle \\frac{x}{11} = 33$" 620 | ], 621 | "text/plain": [ 622 | "x \n", 623 | "── = 33\n", 624 | "11 " 625 | ] 626 | }, 627 | "execution_count": 7, 628 | "metadata": {}, 629 | "output_type": "execute_result" 630 | } 631 | ], 632 | "source": [ 633 | "# Print the equation to the screen\n", 634 | "Eq(x/11, 33)" 635 | ] 636 | }, 637 | { 638 | "cell_type": "code", 639 | "execution_count": 8, 640 | "metadata": {}, 641 | "outputs": [ 642 | { 643 | "data": { 644 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAACYAAAAVCAYAAAAq05ytAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACR0lEQVRIDe2W0W0UMRCGHUQBQAmhgxA6CB0QqCBJB0Q83b2h0EFCBSHp4FICSQnpAJES+D6vx/Ll1qu9lxMPjDTr8Xj8+/eM7bu9xWLxJaV0hirHy+XyYTB3+2XdNR57ELuAwoqBu91SGV8NHpnPy/HhlAjYZywy+Qrb/kVvAwWwhbvGV7O/Ld4oMUAkck4bxBL2R3xm1nLfBgNsCd+U+Jx1fPbVt2iiPxvPeOXF0Gx8T/GcAiiZkCj113CUVgJmJ8Z1S+RRo8g2eHlKj5gleCqaA1nY/poU4gc4r9oB/B/UxjcLr4lPvVK6+9dtYCGh67LxW+onxjZINzGJ8bl4ddoosTpaDICPML0tZ9htdg7xPeIza5/R36jn6qaQwdyUCbwaPEmsLCip96jl+FVnDoZnSTkk9nww82H/Q/8ErZfEMfpuYAovILqHPwcA9IB+R49xXKP32PlC0AapA+w2i879if5oYvQl+l28HNB8eoe/CRlMQN29Z8kyBSkH29tnX7lHjbHUozKBl+NHiTHJLJj25xKlPGJckkq0Q2/9u293Dt76tP475o4tW5uZ53Pte9umYiKbc/HqGqMZY9Qs3DZZiQlRmnhMfTpyViKgtO9ofUYibi5ehekR84atahQGi3jozY5Phgvp89zd0fqUZME25hN6MnjydxZeE5+6/y5YwGvtbQwxM6M/4oWYhJQ36Dd89Qdc51y8grXqvmMEWIYohdhdIba+Yb2gbfDE6JWyh78z/39i26Y6ztglZ8C5/8J/fi/P6i/dPgjAzBQxWAAAAABJRU5ErkJggg==", 645 | "text/latex": [ 646 | "$\\displaystyle \\left[ 363\\right]$" 647 | ], 648 | "text/plain": [ 649 | "[363]" 650 | ] 651 | }, 652 | "execution_count": 8, 653 | "metadata": {}, 654 | "output_type": "execute_result" 655 | } 656 | ], 657 | "source": [ 658 | "# Verify the result\n", 659 | "solve(Eq(x/11, 33), x)" 660 | ] 661 | }, 662 | { 663 | "cell_type": "markdown", 664 | "metadata": {}, 665 | "source": [ 666 | "We can also multiply both sides of the equation by the variable." 667 | ] 668 | }, 669 | { 670 | "cell_type": "markdown", 671 | "metadata": {}, 672 | "source": [ 673 | "__Problem 6.3.4__ Solve the equation in __Equation 6.3.6__." 674 | ] 675 | }, 676 | { 677 | "cell_type": "markdown", 678 | "metadata": {}, 679 | "source": [ 680 | "$$\n", 681 | "\\frac{11}{x} = 33\n", 682 | "\\tag{Equation 6.3.6}\n", 683 | "$$" 684 | ] 685 | }, 686 | { 687 | "cell_type": "markdown", 688 | "metadata": {}, 689 | "source": [ 690 | "The solution is shown in __Equation 6.3.7__." 691 | ] 692 | }, 693 | { 694 | "cell_type": "markdown", 695 | "metadata": {}, 696 | "source": [ 697 | "$$\n", 698 | "\\begin{align*}\n", 699 | "&\\frac{11}{x} \\mathbf{\\times x} = 33 \\mathbf{\\times x} \\\\ \\\\\n", 700 | "&11 = 33x \\\\ \\\\\n", 701 | "&\\frac{11}{33} = \\frac{33x}{33} \\\\ \\\\\n", 702 | "&\\frac{11}{33} = x \\\\ \\\\\n", 703 | "&\\frac{1}{3} = x \\\\ \\\\ \n", 704 | "&x = \\frac{1}{3}\n", 705 | "\\end{align*}\n", 706 | "\\tag{Equation 6.3.7}\n", 707 | "$$" 708 | ] 709 | }, 710 | { 711 | "cell_type": "markdown", 712 | "metadata": {}, 713 | "source": [ 714 | "__Homework 6.3.3__ Solve the equation $\\frac{1}{x} = 5$ by hand or using sympy." 715 | ] 716 | }, 717 | { 718 | "cell_type": "markdown", 719 | "metadata": {}, 720 | "source": [ 721 | "The __reciprocal__ of a fraction is found by inverting the fraction. For example, the reciprocal of $\\frac{1}{3}$ is $\\frac{3}{1}$. This can be useful when solving equations." 722 | ] 723 | }, 724 | { 725 | "cell_type": "markdown", 726 | "metadata": {}, 727 | "source": [ 728 | "__Problem 6.3.5__ Solve the equation in __Equation 6.3.8__." 729 | ] 730 | }, 731 | { 732 | "cell_type": "markdown", 733 | "metadata": {}, 734 | "source": [ 735 | "$$\n", 736 | "\\frac{4}{5}x=12\n", 737 | "\\tag{Equation 6.3.8}\n", 738 | "$$" 739 | ] 740 | }, 741 | { 742 | "cell_type": "markdown", 743 | "metadata": {}, 744 | "source": [ 745 | "The solution is shown in __Equation 6.3.9__." 746 | ] 747 | }, 748 | { 749 | "cell_type": "markdown", 750 | "metadata": {}, 751 | "source": [ 752 | "$$\n", 753 | "\\begin{align*}\n", 754 | "&\\frac{4}{5}x \\mathbf{\\times \\frac{5}{4}} = 12 \\mathbf{\\times \\frac{5}{4}} \\\\ \\\\\n", 755 | "&\\frac{20}{20}x = \\frac{60}{4} \\\\ \\\\\n", 756 | "&x = 15\n", 757 | "\\end{align*}\n", 758 | "\\tag{Equation 6.3.9}\n", 759 | "$$" 760 | ] 761 | }, 762 | { 763 | "cell_type": "markdown", 764 | "metadata": {}, 765 | "source": [ 766 | "The result is verified using `sympy`." 767 | ] 768 | }, 769 | { 770 | "cell_type": "code", 771 | "execution_count": 9, 772 | "metadata": {}, 773 | "outputs": [ 774 | { 775 | "data": { 776 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEkAAAArCAYAAAA0T6WNAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADr0lEQVRoBe2a0VHbQBCGBUMBHtKB6QBCB04HIVSQ0EGYPMFbBjoAKkigA5wKCHQAJRB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hzctXoFbuglT60g6TGwF4/PkaGYPLWChPXeVzUB4UExA8ClSN7TQDoHiKa8Y9Ku/ZOFwKVI00DyZnOifEA7//flojiVIjBlm6auboDSZ0JejDLMPMt5Tz4qvyjl578pO/1nr+gB9gAAAABJRU5ErkJggg==", 777 | "text/latex": [ 778 | "$\\displaystyle \\frac{4 x}{5} = 12$" 779 | ], 780 | "text/plain": [ 781 | "4⋅x \n", 782 | "─── = 12\n", 783 | " 5 " 784 | ] 785 | }, 786 | "execution_count": 9, 787 | "metadata": {}, 788 | "output_type": "execute_result" 789 | } 790 | ], 791 | "source": [ 792 | "# Print the problem to the screen\n", 793 | "Eq(Rational(4, 5)*x, 12)" 794 | ] 795 | }, 796 | { 797 | "cell_type": "code", 798 | "execution_count": 10, 799 | "metadata": {}, 800 | "outputs": [ 801 | { 802 | "data": { 803 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABwAAAAVCAYAAABVAo5cAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABf0lEQVRIDd2W31HCQBDGT8cCGK3A2AFYApZAC9qBPiZvDnYAdiB2gJYAJViCYwfx9yVekiV3ihzy4M58l93N7n73Z3NwlOf5rXPuBkgmRVGsa3U/I/VMfQfhFIzLsnS7gNzhZh6+Aci6fuyK5+SndTDDITELMEL/CMS/4h/g9zsjXTKqH3YMEn4VeCT0HVyCzKYZSzESTewNPIP7yORcjFArmQBHos5AxWKyJqaKjQV0/cdd4xD6wQmDW/rblbKl1+SoWc6Azltn6JsIs5V9rFBETxA8gDt0YYU+bmlaLZmQwldATVYJujr1Bcxqjx2TCW25xhJpBrm210gSIQWXYGUqWkPbbSSJkEq6FHpF8Z2Khcn0GieVcE7RCxXfEDWMzrEn2xCq1SXVrGu1GWcQmubA1s0kCd4+0e+QRF3YEt/eC3xqBp3bXC9kgynwpJqU7tZzfE3nKtbLd4TBGfpE/xQpuv899e7oc5stjSbv8uL/E/ozVLdph/7yP40aavkJMESx0w6T0T0AAAAASUVORK5CYII=", 804 | "text/latex": [ 805 | "$\\displaystyle \\left[ 15\\right]$" 806 | ], 807 | "text/plain": [ 808 | "[15]" 809 | ] 810 | }, 811 | "execution_count": 10, 812 | "metadata": {}, 813 | "output_type": "execute_result" 814 | } 815 | ], 816 | "source": [ 817 | "# Verify the result\n", 818 | "solve(Eq((Rational(4, 5))*x, 12), x)" 819 | ] 820 | }, 821 | { 822 | "cell_type": "markdown", 823 | "metadata": {}, 824 | "source": [ 825 | "__Homework 6.3.4__ Solve the equation $\\frac{3}{4}x = 12$ (by hand or by using sympy)." 826 | ] 827 | }, 828 | { 829 | "cell_type": "markdown", 830 | "metadata": {}, 831 | "source": [ 832 | "It might be necessary to distribute a variable before isolating it. In __Problem 6.3.6__ we see an example of this, where we use parentheses and brackets to make the order of operations clear." 833 | ] 834 | }, 835 | { 836 | "cell_type": "markdown", 837 | "metadata": {}, 838 | "source": [ 839 | "__Problem 6.3.6__ Solve the equation in __Equation 6.3.10__." 840 | ] 841 | }, 842 | { 843 | "cell_type": "markdown", 844 | "metadata": {}, 845 | "source": [ 846 | "$$\n", 847 | "3 \\left[ 4x+5(x-2) \\right] + 6 = 1 - 2 \\left[ 9 - 2(x-4) \\right]\n", 848 | "\\tag{Equation 6.3.10}\n", 849 | "$$" 850 | ] 851 | }, 852 | { 853 | "cell_type": "markdown", 854 | "metadata": {}, 855 | "source": [ 856 | "The solution is shown in __Equation 6.3.11__ and is verified using `sympy`." 857 | ] 858 | }, 859 | { 860 | "cell_type": "markdown", 861 | "metadata": {}, 862 | "source": [ 863 | "$$\n", 864 | "\\begin{align*}\n", 865 | "&3 (4x + 5x -10) + 6 = 1 - 2 (9 - 2x + 8) \\\\ \\\\\n", 866 | "&3 (9x - 10) + 6 = 1 - 2 (-2x + 17) \\\\ \\\\\n", 867 | "&27x - 30 + 6 = 1 + 4x - 34 \\\\ \\\\\n", 868 | "&27x - 24 = 4x - 33 \\\\ \\\\\n", 869 | "&27x - 4x = -33 + 24 \\\\ \\\\\n", 870 | "&23x = -9 \\\\ \\\\\n", 871 | "&x = -\\frac{9}{23}\n", 872 | "\\end{align*}\n", 873 | "\\tag{Equation 6.3.11}\n", 874 | "$$" 875 | ] 876 | }, 877 | { 878 | "cell_type": "code", 879 | "execution_count": 11, 880 | "metadata": {}, 881 | "outputs": [ 882 | { 883 | "data": { 884 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAK0AAAAPCAYAAACWe0+mAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEa0lEQVRoBe2Z7VHcMBCGjwwFACWQDgh0QDoIoQKggzD8gn8Z6ICkg0AHIRXw0QGUQOiAPI+xHFuWz3Ymdydm2Bmd5NWr1e5qtZJ9S8/Pz5MhdHJysg5um/KD9tOQMW+YNw/MwgNLBm0ZkIflBJvUj5RD+HdhUtqfaF+E50T9BGY1wc+GNcTOlLKM24B/QH2Q6l8UL1e9uvxR+j/4cAWcifAU/lV9TB9uuQScU38MA2mf0r6VRwkCt+DZfgi4Wm0GDkFfY+fTxA4dNMTOlNJu1moDpwAL4uWqV8sd+N8gNRGGoJ3QNhH+pN6hXDqIuhf3DpwBWgkqBxqAXgEamRWBBnGRcUINxvFXPBeT0s6VBttZNwC7vtSfc2nnqtcU/+zTt4/eBmqgkBCPAoO6F2fQmiXvEWaE10mBK/DNUNL1S9X6Nb03gr6FyIMx1M5KW+zyWuDmtWRDuerV4yBPqoYvsSPl117cMoIMzo0OAeqx4g/9rUwKz+z11f5XQIPsjOzYxcbGkRb1L+oxV706/YEf9X/jnQdeyLrnYeAQnHfanTAgqs0yE/qTdzn4ZmCDvXWXhWegm+Yl78J7FPG7FOkaTGsTvHTN5pf5RtkJ3mtB5czZaDVe6hC9wGTn/9hSdPTkK65stL/F/eE5hTPTtgigAWuQtQKyBnZCS4qqKwOyXPzvFAPVrGUgOG6uQct8LeqyE762+zUk9dLZkhMzShtdlDF0x7iujVXIGaFXtv7HBmNL35jMTIg3lBZNwyWDFgm+gF0y8KwlDQZ8F3WbuuVkeGbYejB7b/EYMNtKa5R6f8Fc0E+Xnb5sTtuwU9Vl7Kzu+L165e5/9DNQi9ObtnHhV6rq60Fw7DRcK2gBmwkfFBQEJGoXpSsL3TC23vcBrFnE4J30yBUixuPtF8V6KGl48iqTEgA2aSd8N12O14Kher0K/7sm+NrEaFxcUK+WbbsaFOMaQUunjlmjrr7ZNkb/fXCH1AOz6mFsHDif6Rz1soYMDTHYZ0JddsL3BPGLSdK2mSgzQOgYvcBm6X/06npH8nrgdcFiEPfiqqAFbCC+p64yLG0XcUJdLSJts5/82DlCGwRWRcRX99dy/ITawJw7MW+nnSijXVtgGt+n4enI9ZLvKTT16kC/mVrbx9C0O+0/6YUeOfn/VmegU2dGLZ3ViyuCFkEuiosVL4YLHL/ZbZbCH8u6qhhvgLrg4a85rxHxC81RYp5KxiwbfXbS7+b000yD4P+G4R8o1YZuAKIHcP/1Tos8derVC1zO/jdJ6cM4WYV4Cvb14pYR4i420BQY3+W24cUvYzpGiieX5862+JVAXCOw4dl3TZk7MfdYO+s6akuwu85fdDvWK1v/46g4IU5YE5OiNviC+VQ6sxe3dHx8fA/YBU2RR1bjbsmzWFP4Hu3q2HcwzyrglwFl+nxGUTHvyI555LkxBt5ciHlH2alSjHETa6/BIKm7n+7ijVx0zuunSy/m91TM0v/6Br31Y/200rfhVBZSUB/uD3BqfNWWAT80AAAAAElFTkSuQmCC", 885 | "text/latex": [ 886 | "$\\displaystyle 27 x - 24 = 4 x - 33$" 887 | ], 888 | "text/plain": [ 889 | "27⋅x - 24 = 4⋅x - 33" 890 | ] 891 | }, 892 | "execution_count": 11, 893 | "metadata": {}, 894 | "output_type": "execute_result" 895 | } 896 | ], 897 | "source": [ 898 | "# Print the problem to the screen\n", 899 | "Eq(3 * (4 * x + 5 * (x - 2)) + 6, 1 - 2 * (9 - 2 * (x - 4)))" 900 | ] 901 | }, 902 | { 903 | "cell_type": "code", 904 | "execution_count": 12, 905 | "metadata": {}, 906 | "outputs": [ 907 | { 908 | "data": { 909 | "image/png": "iVBORw0K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OeYdOpYjv2GLdRxbsHtrHgJKRmgWfEVJ16OJfNZAUtIjxSBOBnmnnxKWe1F6I6ZTP2hAjvmViut+OAX8TgOiMXmOC/eT6cG57d6ICeh+DkDOp30pt1Yllzse33ZVYOj+DbGhZdDmGOsIXSeItlt1n3BAISPFLRiOh5UiHSj+M6Z9tS8Ed6nTsoQsYP8HM10cWUvUWBYAAAAASUVORK5CYII=", 910 | "text/latex": [ 911 | "$\\displaystyle \\left[ - \\frac{9}{23}\\right]$" 912 | ], 913 | "text/plain": [ 914 | "[-9/23]" 915 | ] 916 | }, 917 | "execution_count": 12, 918 | "metadata": {}, 919 | "output_type": "execute_result" 920 | } 921 | ], 922 | "source": [ 923 | "# Verify the result\n", 924 | "solve(Eq(3 * (4 * x + 5 * (x - 2)) + 6, 1 - 2 * (9 - 2 * (x - 4))), x)" 925 | ] 926 | }, 927 | { 928 | "cell_type": "markdown", 929 | "metadata": {}, 930 | "source": [ 931 | "__Homework 6.3.4__ Solve the equation $3 [ x + (x - 3)] = 4x + 5$ (by hand or by using sympy)." 932 | ] 933 | }, 934 | { 935 | "cell_type": "markdown", 936 | "metadata": {}, 937 | "source": [ 938 | "__Problem 6.3.7__ Solve the equation in __Equation 6.3.12__." 939 | ] 940 | }, 941 | { 942 | "cell_type": "markdown", 943 | "metadata": {}, 944 | "source": [ 945 | "__Equation 6.3.12__" 946 | ] 947 | }, 948 | { 949 | "cell_type": "markdown", 950 | "metadata": {}, 951 | "source": [ 952 | "$$\n", 953 | "\\frac{3(x-2)}{4} + \\frac{1}{2}(5x+2) = \\frac{14x+12}{8} + 7\n", 954 | "\\tag{Equation 6.3.12}\n", 955 | "$$" 956 | ] 957 | }, 958 | { 959 | "cell_type": "markdown", 960 | "metadata": {}, 961 | "source": [ 962 | "The solution is shown in __Equation 6.3.13__ and is verified using `sympy`." 963 | ] 964 | }, 965 | { 966 | "cell_type": "markdown", 967 | "metadata": {}, 968 | "source": [ 969 | "$$\n", 970 | "\\begin{align*}\n", 971 | "&\\frac{3(x-2)}{4} + \\frac{1}{2}(5x+2) = \\frac{14x+12}{8} + 7 \\\\ \\\\\n", 972 | "&8 \\left[ \\frac{3(x-2)}{4} + \\frac{1}{2}(5x+2) \\right] = 8 \\left[ \\frac{14x+12}{8} + 7 \\right] \\\\ \\\\\n", 973 | "&6(x-2)+4(5x+2)=14x+12+56 \\\\ \\\\\n", 974 | "&6x-12+20x+8=14x+12+56 \\\\ \\\\\n", 975 | "&26x-4=14x+68 \\\\ \\\\\n", 976 | "&26x-14x=68+4 \\\\ \\\\\n", 977 | "&12x=72 \\\\ \\\\\n", 978 | "&x=6\n", 979 | "\\end{align*}\n", 980 | "\\tag{Equation 6.3.13}\n", 981 | "$$" 982 | ] 983 | }, 984 | { 985 | "cell_type": "code", 986 | "execution_count": 13, 987 | "metadata": {}, 988 | "outputs": [ 989 | { 990 | "data": { 991 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABIAAAAVCAYAAABLy77vAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABVElEQVQ4Ec2U31ECMRDGg0MBjiVgB0gHDB0oVsDQgTzevVoCWoFiB9CClkAHjpTg77tcjoRN8uCTO/Nd9t+32WTvbtQ0zZNzbg0kD23bfnm1/iQv4Y0o9AxlT+BQp+aj8Dr+OB8+e/vEs8O5N3ym62Ihkiewd2CD3nXLKlu4BYlcJVZqiKDd4yNf4zumad7KdgT5nvAUzGMS/kVsx3qpI03xBPEUJ9f0bEcQZuBIIXX1CL6B7mWHLz4qLi+lQroLyQzixqvOof+AFfgIvrCao5EUikzRX0Jiv76zvkY5Q9gUGiL56XwS10Y6eiKmELuFCw5rQuiNyaXTFOoTdKHhiJcc2eZdKhXakmx2xXcH9FqYyWULkaipHFj1QXaCrg6XYOU96bM0fgdxoUJA3UluwBzbfLAKFgspCGl4h2TXJHu0GqEU+3+Fwh1tuQ91/Zd/toaw/wWUsWRLJ/aFqgAAAABJRU5ErkJggg==", 992 | "text/latex": [ 993 | "$\\displaystyle \\left[ 6\\right]$" 994 | ], 995 | "text/plain": [ 996 | "[6]" 997 | ] 998 | }, 999 | "execution_count": 13, 1000 | "metadata": {}, 1001 | "output_type": "execute_result" 1002 | } 1003 | ], 1004 | "source": [ 1005 | "# Verify the result\n", 1006 | "solve(Eq(Rational(3, 4) * (x - 2) + Rational(1, 2) * (5 * x +2), Rational(1, 8) * (14 * x + 12) + 7), x)" 1007 | ] 1008 | }, 1009 | { 1010 | "cell_type": "markdown", 1011 | "metadata": {}, 1012 | "source": [ 1013 | "There are two more properties of equations that are demonstrated using variables in __Equation 6.3.14__, where $b \\ne 0$ and $d \\ne 0$, and in __Equation 6.3.15__, where $b \\ne 0$, $d \\ne 0$, and $e \\ne 0$." 1014 | ] 1015 | }, 1016 | { 1017 | "cell_type": "markdown", 1018 | "metadata": {}, 1019 | "source": [ 1020 | "By the property in __Equation 6.3.14__ we can multiply both sides of an equation by the denominator of a fraction to remove the fraction." 1021 | ] 1022 | }, 1023 | { 1024 | "cell_type": "markdown", 1025 | "metadata": {}, 1026 | "source": [ 1027 | "$$\n", 1028 | "\\begin{align*}\n", 1029 | "&\\frac{a}{b} = \\frac{c}{d} \\\\ \\\\\n", 1030 | "&bd \\times \\frac{a}{b} = bd \\times\\frac{c}{d} \\text{ (multiply both sides by the product of the denominators } bd \\text{)} \\\\ \\\\\n", 1031 | "&\\frac{b}{b}ad = \\frac{c}{c}bc \\text{ (rearrange)} \\\\ \\\\\n", 1032 | "&ad = bc\n", 1033 | "\\end{align*}\n", 1034 | "\\tag{Equation 6.3.14}\n", 1035 | "$$\n" 1036 | ] 1037 | }, 1038 | { 1039 | "cell_type": "markdown", 1040 | "metadata": {}, 1041 | "source": [ 1042 | "We can also multiply both sides of an equation by a variable in the numerator of a fraction to remove it. This is shown in __Equation 6.3.15__." 1043 | ] 1044 | }, 1045 | { 1046 | "cell_type": "markdown", 1047 | "metadata": {}, 1048 | "source": [ 1049 | "$$\n", 1050 | "\\begin{align*}\n", 1051 | "&\\frac{ef}{b} = \\frac{eg}{d} \\text{ (note that } e \\text{ is common to both numerators)} \\\\ \\\\\n", 1052 | "&\\frac{1}{e}\\frac{ef}{b} = \\frac{1}{e}\\frac{eg}{d} \\text{ (multiply both sides by } \\frac{1}{e} \\text{)} \\\\ \\\\\n", 1053 | "&\\frac{e}{e} \\frac{f}{b} = \\frac{e}{e} \\frac{g}{d} \\text{ (rearrange)} \\\\ \\\\\n", 1054 | "&\\frac{f}{b} = \\frac{g}{d}\n", 1055 | "\\end{align*}\n", 1056 | "\\tag{Equation 6.3.15}\n", 1057 | "$$" 1058 | ] 1059 | }, 1060 | { 1061 | "cell_type": "markdown", 1062 | "metadata": {}, 1063 | "source": [ 1064 | "We make use of these properties in __Problem 6.3.8__." 1065 | ] 1066 | }, 1067 | { 1068 | "cell_type": "markdown", 1069 | "metadata": {}, 1070 | "source": [ 1071 | "__Problem 6.3.8__ Solve the equation in __Equation 6.3.16__." 1072 | ] 1073 | }, 1074 | { 1075 | "cell_type": "markdown", 1076 | "metadata": {}, 1077 | "source": [ 1078 | "$$\n", 1079 | "\\frac{3x-5}{x+3} = \\frac{24}{15}\n", 1080 | "$$" 1081 | ] 1082 | }, 1083 | { 1084 | "cell_type": "markdown", 1085 | "metadata": {}, 1086 | "source": [ 1087 | "We start by multiplying both sides of the equation by $15(x+3)$ which is the product of the denominators in __Equation 6.3.16__. This _removes_ the denominators in the equation." 1088 | ] 1089 | }, 1090 | { 1091 | "cell_type": "markdown", 1092 | "metadata": {}, 1093 | "source": [ 1094 | "$$\n", 1095 | "\\begin{align*}\n", 1096 | "&15(x+3)\\frac{3x-5}{x+3} = 15(x+3)\\frac{24}{15} \\\\ \\\\\n", 1097 | "&15(3x-5) = 24(x+3) \\\\ \\\\\n", 1098 | "&45x-75 = 24x+72 \\\\ \\\\\n", 1099 | "&45x-24x = 72+75 \\\\ \\\\\n", 1100 | "&21x = 147 \\\\ \\\\\n", 1101 | "&x = 7\n", 1102 | "\\end{align*}\n", 1103 | "\\tag{Equation 6.3.16}\n", 1104 | "$$" 1105 | ] 1106 | }, 1107 | { 1108 | "cell_type": "markdown", 1109 | "metadata": {}, 1110 | "source": [ 1111 | "We verify the solution using `sympy`." 1112 | ] 1113 | }, 1114 | { 1115 | "cell_type": "code", 1116 | "execution_count": 14, 1117 | "metadata": {}, 1118 | "outputs": [ 1119 | { 1120 | "data": { 1121 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABIAAAAVCAYAAABLy77vAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABGUlEQVQ4Ec2U3Q2CQBCE0ViAWgIlEO1AO5Aa7EAf4c1Ygi0YO8AOTCzBEgwl+A0/Bo49MPriJssdsztze8ceoyRJdkEQbHFZnKbpvZz2P8lr8UYIHaFkBK41lXnIfIWfmec1bo3EC/7ECoJF+ElOIkPHcvBZE/UJLUlShY9mcjVXpXsX9wkFrLh2k8G0ZcUubswndHMTq/cjIrEVG1ugtSKYDvVg5QszhdxkRLSliNHbGh8JIaJq5F4bFKqqWTG++8xSGxSCpK632qCl94nQBsazxTJeeoXYzhROiPdeE+n2ChFfKAn7rSIEVJHs54rUNxLxdboWKcx3RYogZ6Sv1brlJa37HDqjLsOD/J9QfUb1n/Cbf/ac3WYvC6RHixtPYlQAAAAASUVORK5CYII=", 1122 | "text/latex": [ 1123 | "$\\displaystyle \\left[ 7\\right]$" 1124 | ], 1125 | "text/plain": [ 1126 | "[7]" 1127 | ] 1128 | }, 1129 | "execution_count": 14, 1130 | "metadata": {}, 1131 | "output_type": "execute_result" 1132 | } 1133 | ], 1134 | "source": [ 1135 | "# Verify the result\n", 1136 | "solve(Eq((3 * x - 5) / (x + 3), Rational(24, 15)), x)" 1137 | ] 1138 | }, 1139 | { 1140 | "cell_type": "markdown", 1141 | "metadata": {}, 1142 | "source": [ 1143 | "__Homework 6.3.5__ Solve __Equation 6.3.17__." 1144 | ] 1145 | }, 1146 | { 1147 | "cell_type": "markdown", 1148 | "metadata": {}, 1149 | "source": [ 1150 | "$$\n", 1151 | "\\frac{2x-3}{x+4} = \\frac{5}{3}\n", 1152 | "\\tag{Equation 6.3.17}\n", 1153 | "$$" 1154 | ] 1155 | }, 1156 | { 1157 | "cell_type": "markdown", 1158 | "metadata": {}, 1159 | "source": [ 1160 | "## 6.4 Solving formulas" 1161 | ] 1162 | }, 1163 | { 1164 | "cell_type": "markdown", 1165 | "metadata": {}, 1166 | "source": [ 1167 | "Formulas are equation that are used to calculate a value. The formula for the area of a circle is an example. This formula is shown in __Equation 6.4.1__, where $A$ is the area and $r$ is the radius (or half the diameter) of the circle." 1168 | ] 1169 | }, 1170 | { 1171 | "cell_type": "markdown", 1172 | "metadata": {}, 1173 | "source": [ 1174 | "$$\n", 1175 | "A = \\pi r^{2}\n", 1176 | "\\tag{Equation 6.4.1}\n", 1177 | "$$" 1178 | ] 1179 | }, 1180 | { 1181 | "cell_type": "markdown", 1182 | "metadata": {}, 1183 | "source": [ 1184 | "If we know the area in __Equation 6.4.1__ then we can solve for the radius, $r$. The process of solving for a variable in a formula is the same as solving an equation for that variable. We can use the rules in __Section 6.2__ and in __Section 6.3__ to solve for the variable. We solve for the radius in __Equation 6.4.1__ in __Equation 6.4.2__." 1185 | ] 1186 | }, 1187 | { 1188 | "cell_type": "markdown", 1189 | "metadata": {}, 1190 | "source": [ 1191 | "$$\n", 1192 | "\\begin{align*}\n", 1193 | "&A = \\pi r^{2} \\\\ \\\\\n", 1194 | "&\\frac{A}{\\pi} = \\frac{\\pi r^{2}}{\\pi} \\\\ \\\\\n", 1195 | "&\\frac{A}{\\pi} = r^{2} \\\\ \\\\\n", 1196 | "&\\sqrt{\\frac{A}{\\pi}} = \\sqrt{r^{2}} \\\\ \\\\\n", 1197 | "&\\sqrt{\\frac{A}{\\pi}} = r \\\\ \\\\\n", 1198 | "&r = \\sqrt{\\frac{A}{\\pi}}\n", 1199 | "\\end{align*}\n", 1200 | "\\tag{Equation 6.4.2}\n", 1201 | "$$" 1202 | ] 1203 | }, 1204 | { 1205 | "cell_type": "markdown", 1206 | "metadata": {}, 1207 | "source": [ 1208 | "In public health research we often calculate the mean of a set of numbers taken from a sample of people. These numbers are called random variables and are random numbers for a statistical variable such as age or height or serum glucose level. The people in a study are randomly selected from a population. Th mean of the random variables in the sample is denoted by $\\bar{X}$ and the mean of the variable values in the population is denoted by $\\mu$." 1209 | ] 1210 | }, 1211 | { 1212 | "cell_type": "markdown", 1213 | "metadata": {}, 1214 | "source": [ 1215 | "In most cases, we do not have data from a population. We only have data from a sample. We can use the mean of the sample to estimate the mean of the population. Once we have calculated the mean of the sample, we can use the formula in __Equation 6.4.3__ to calculate an interval estimate for the mean of the population." 1216 | ] 1217 | }, 1218 | { 1219 | "cell_type": "markdown", 1220 | "metadata": {}, 1221 | "source": [ 1222 | "The interval estimate has a lower and an upper value, and we express some level of confidence that the true population mean is within these bounds. The formula in __Equation 6.4.3__ calculates the lower an upper bounds given values of the sample mean, $\\bar{X}$, the sample standard deviation, $s$, the sample size, $n$, and the confidence coefficient, $c$." 1223 | ] 1224 | }, 1225 | { 1226 | "cell_type": "markdown", 1227 | "metadata": {}, 1228 | "source": [ 1229 | "$$\n", 1230 | "\\begin{align*}\n", 1231 | "&\\text{lower bound} = \\bar{X} - c \\frac{s}{\\sqrt{n}} \\\\ \\\\\n", 1232 | "&\\text{upper bound} = \\bar{X} + c \\frac{s}{\\sqrt{n}} \\\\ \\\\\n", 1233 | "\\end{align*}\n", 1234 | "\\tag{Equation 6.4.3}\n", 1235 | "$$" 1236 | ] 1237 | }, 1238 | { 1239 | "cell_type": "markdown", 1240 | "metadata": {}, 1241 | "source": [ 1242 | "The difference, $\\mathtt{upper bound - lower bound}$, is sometimes called the __width__." 1243 | ] 1244 | }, 1245 | { 1246 | "cell_type": "markdown", 1247 | "metadata": {}, 1248 | "source": [ 1249 | "__Problem 6.4.1__ Calculate the confidence coefficient, $c$, if $\\bar{X}=100$, the sample standard deviation, $s$, is $10$, the sample size, $n$, is $100$, and the width is $20$." 1250 | ] 1251 | }, 1252 | { 1253 | "cell_type": "markdown", 1254 | "metadata": {}, 1255 | "source": [ 1256 | "We build the solution in __Equation 6.4.4__." 1257 | ] 1258 | }, 1259 | { 1260 | "cell_type": "markdown", 1261 | "metadata": {}, 1262 | "source": [ 1263 | "$$\n", 1264 | "\\begin{align*}\n", 1265 | "&\\text{width} = \\text{upper bound} - \\text{lower bound} \\\\ \\\\\n", 1266 | "&20 = \\bar{X} + c \\frac{s}{\\sqrt{n}} - \\left( \\bar{X} - c \\frac{s}{\\sqrt{n}} \\right) \\\\ \\\\\n", 1267 | "&20 = \\bar{X} + c \\frac{s}{\\sqrt{n}} - \\bar{X} + c \\frac{s}{\\sqrt{n}} \\\\ \\\\\n", 1268 | "&20 = 2c \\frac{s}{\\sqrt{n}} \\\\ \\\\\n", 1269 | "&\\frac{20}{2} = c \\frac{s}{\\sqrt{n}} \\\\ \\\\\n", 1270 | "&10 = c \\frac{s}{\\sqrt{n}} \\\\ \\\\\n", 1271 | "&c = \\frac{10 \\sqrt{n}}{s} \\\\ \\\\\n", 1272 | "&c = \\frac{10 \\sqrt{30}}{10} \\\\ \\\\\n", 1273 | "&c \\approx 5.48\n", 1274 | "\\end{align*}\n", 1275 | "\\tag{Equation 6.4.4}\n", 1276 | "$$" 1277 | ] 1278 | }, 1279 | { 1280 | "cell_type": "code", 1281 | "execution_count": null, 1282 | "metadata": {}, 1283 | "outputs": [], 1284 | "source": [] 1285 | } 1286 | ], 1287 | "metadata": { 1288 | "kernelspec": { 1289 | "display_name": "mathematics", 1290 | "language": "python", 1291 | "name": "python3" 1292 | }, 1293 | "language_info": { 1294 | "codemirror_mode": { 1295 | "name": "ipython", 1296 | "version": 3 1297 | }, 1298 | "file_extension": ".py", 1299 | "mimetype": "text/x-python", 1300 | "name": "python", 1301 | "nbconvert_exporter": "python", 1302 | "pygments_lexer": "ipython3", 1303 | "version": "3.10.9" 1304 | }, 1305 | "orig_nbformat": 4 1306 | }, 1307 | "nbformat": 4, 1308 | "nbformat_minor": 2 1309 | } 1310 | -------------------------------------------------------------------------------- /Lecture07QuadraticEquations.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 7 | QUADRATIC EQUATIONS" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | ">Dr J H Klopper

\n", 15 | ">Department of Biostatistics and Bioinformatics
\n", 16 | ">Milken Institute School of Public Health
\n", 17 | ">George Washington University" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "

This chapter of Algebra for Health Data Science by Dr JH Klopper is licensed under Attribution-NonCommercial-NoDerivatives 4.0 International

" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "- Watch the pencil and paper video lecture [HERE](https://youtu.be/8wv33jF104Y)\n", 32 | "\n", 33 | "- Watch the Python video lecture [HERE](https://youtu.be/4WBExAz9uPY)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "## 7.1 Packages used in the chapter" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "We import the specific function from the `sympy` package that we will use in the chapter." 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 2, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "from sympy import init_printing, symbols, Eq, solve, Rational, I, sqrt" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "The `init_printing` function is used to display the output in a format that is easier to read." 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 3, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "init_printing()" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## 7.2 Introduction" 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": {}, 85 | "source": [ 86 | "In this chapter we will examine how to solve quadratic equations using factorization and the quadratic formula, building on our exploration in the previous chapter. We will also meet a new type of number, the complex numbers, which will help us solve quadratic equations that have no real solutions." 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "We start by defining the quadratic equation." 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "## 7.3 Quadratic equations" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "__Definition 7.3.1__ A __quadratic equation__ is an equation of the form $ax^2 + bx + c = 0$ where $a, b, c \\in \\mathbb{R}$ and $a \\neq 0$." 108 | ] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "metadata": {}, 113 | "source": [ 114 | "Note that our definition used the coefficients $a,b$, and $c$. This would be similar to our notation in the previous lecture, where we wrote $a_{2}x^{2} + a_{2}x + a_{0}=0$. Simply stated, $a=a_{2}, b=a_{1}$, and $c=a_{0}$ in the notation that we use in this chapter." 115 | ] 116 | }, 117 | { 118 | "cell_type": "markdown", 119 | "metadata": {}, 120 | "source": [ 121 | "Quadratic equations are polynomials of degree $2$. That is to say that we have a single variable, usually denoted by $x$, and the highest power of $x$ is $2$. The coefficients $a, b, c$ are real numbers. We will see later that the solutions to a quadratic equation are real numbers and that they can be complex numbers as well." 122 | ] 123 | }, 124 | { 125 | "cell_type": "markdown", 126 | "metadata": {}, 127 | "source": [ 128 | "We often solve quadratic equations by factoring, which we explore in the next section. Note that because $x$ is squared, we will have two solutions to a quadratic equation." 129 | ] 130 | }, 131 | { 132 | "cell_type": "markdown", 133 | "metadata": {}, 134 | "source": [ 135 | "__Definition 7.3.2__ The solutions to a quadratic equation $ax^2 + bx + c = 0$ are called the __roots__ of the quadratic equation." 136 | ] 137 | }, 138 | { 139 | "cell_type": "markdown", 140 | "metadata": {}, 141 | "source": [ 142 | "In the last chapter in this textbook, we explore graphing of equations. In the graph of an equation on a Cartesian plane, we have that the real roots are the $x$ intercepts of the graph. That is where $y=0$ (where $y$ is the vertical axis). Real roots are the points where the graph _crosses_ the $x$ axis. We call this intersecting the $x$ axis." 143 | ] 144 | }, 145 | { 146 | "cell_type": "markdown", 147 | "metadata": {}, 148 | "source": [ 149 | "## 7.4 Factoring to solve quadratic equations" 150 | ] 151 | }, 152 | { 153 | "cell_type": "markdown", 154 | "metadata": {}, 155 | "source": [ 156 | "To find the roots of a quadratic equation, we need to solve for $x$." 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "The left-hand side of the quadratic equation $ax^2 + bx + c = 0$ is a polynomial expression of degree $2$. We have already explored the factoring of these expressions." 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "__Problem 7.4.1__ Solve the quadratic equation $x^2 + 5x + 6 = 0$." 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "We see the start of the solution to this equation in __Equation 7.4.1__, where we factor the left-hand side of the equation. We note that $2 \\times 3 = 6$, which will help our cause." 178 | ] 179 | }, 180 | { 181 | "cell_type": "markdown", 182 | "metadata": {}, 183 | "source": [ 184 | "$$\n", 185 | "\\begin{align*}\n", 186 | "&\\left( x \\quad \\right)\\left( x \\quad \\right) = 0 \\\\ \\\\\n", 187 | "&\\left( x + 2 \\right)\\left( x + 3 \\right) = 0\n", 188 | "\\end{align*}\n", 189 | "\\tag{Equation 7.4.2}\n", 190 | "$$" 191 | ] 192 | }, 193 | { 194 | "cell_type": "markdown", 195 | "metadata": {}, 196 | "source": [ 197 | "By multiplication we verify the result. We have that $x^{2} + 3x + 2x + 6 = x^{2} + 5x + 6 = 0$." 198 | ] 199 | }, 200 | { 201 | "cell_type": "markdown", 202 | "metadata": {}, 203 | "source": [ 204 | "For the statement $a \\times b = 0$ it must hold that either $a=0$ and / or $b=0$. This is the __zero product property__. Therefor, we can continue our solution as is shown in __Equation 7.4.2__." 205 | ] 206 | }, 207 | { 208 | "cell_type": "markdown", 209 | "metadata": {}, 210 | "source": [ 211 | "$$\n", 212 | "\\begin{align*}\n", 213 | "&\\left( x + 2 \\right)\\left( x + 3 \\right) = 0 \\\\ \\\\\n", 214 | "&x + 2 = 0 \\quad \\text{or} \\quad x + 3 = 0 \\\\ \\\\\n", 215 | "&x = -2 \\quad \\text{or} \\quad x = -3\n", 216 | "\\end{align*}\n", 217 | "\\tag{Equation 7.4.2}\n", 218 | "$$" 219 | ] 220 | }, 221 | { 222 | "cell_type": "markdown", 223 | "metadata": {}, 224 | "source": [ 225 | "We verify these results by substituting the solutions into the original equation. This is shown in __Equation 7.4.3__, where we have that $x=-2$." 226 | ] 227 | }, 228 | { 229 | "cell_type": "markdown", 230 | "metadata": {}, 231 | "source": [ 232 | "$$\n", 233 | "\\begin{align*}\n", 234 | "&x^2 + 5x + 6 = 0 \\\\ \\\\\n", 235 | "&\\left( -2 \\right)^2 + 5\\left( -2 \\right) + 6 = 0 \\\\ \\\\\n", 236 | "&4 - 10 + 6 = 0 \\\\ \\\\\n", 237 | "&0 = 0\n", 238 | "\\end{align*}\n", 239 | "\\tag{Equation 7.4.3}\n", 240 | "$$" 241 | ] 242 | }, 243 | { 244 | "cell_type": "markdown", 245 | "metadata": {}, 246 | "source": [ 247 | "In __Equation 7.4.4__ we have that $x=-3$." 248 | ] 249 | }, 250 | { 251 | "cell_type": "markdown", 252 | "metadata": {}, 253 | "source": [ 254 | "$$\n", 255 | "\\begin{align*}\n", 256 | "&x^2 + 5x + 6 = 0 \\\\ \\\\\n", 257 | "&\\left( -3 \\right)^2 + 5\\left( -3 \\right) + 6 = 0 \\\\ \\\\\n", 258 | "&9 - 15 + 6 = 0 \\\\ \\\\\n", 259 | "&0 = 0\n", 260 | "\\end{align*}\n", 261 | "\\tag{Equation 7.4.4}\n", 262 | "$$" 263 | ] 264 | }, 265 | { 266 | "cell_type": "markdown", 267 | "metadata": {}, 268 | "source": [ 269 | "We can also use `sympy` to solve this equation. We start by assigning the mathematical symbol $x$ to the variable `x` using the `symbols` function. Next, we use the `Eq` function to create the equation and assign it to the variable `eq` that we print to the screen." 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": 4, 275 | "metadata": {}, 276 | "outputs": [ 277 | { 278 | "data": { 279 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI4AAAAVCAYAAACQXNaIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAENklEQVRoBe2Z7VEbMRCGDUMBDlQQ0gEhFQAd5KMCSAfJ8Av+MaQDoIJAOoBUwEcH0EESOiDPI04a+Thj7mzOB+OdkaVbfdy7e6vdlTx3d3fXq0u7u7t95mwX85aLehP+bd21ZuNfpgYWGsLex0i+xrm0D2hfUt5F3qx+3RqYbyjeFsayns3dp70MbyXjzZqvWANNDUdvc/GK9TITbZQGzHHGLTs7O/uU63HXaTqfd6+U58LrU5bL/Nnz+N9bHTbNcZI9FuHpI4z3idl+4zc4TNivilfblqaJ6R7BE3/Bb7jP6Se8KE/Ob62dYfrDS81fzW1vBDCW4bCIJyoFfk97mieqvwoDmWMp2C/K3pQxAWE0FTo8YeR32mfOoPbZMrXDBhg87KhDdSkmN+Ml9QblprHhMFmjUdiNYmGfey5qXYeYY6Jtcn1YZ1429oq5n7Ln1poTwK6B6F2C0RTA/Ui19TgpocGyxVp96mA0rkv7tnj2BL3RyHBYQCNxAQ0nnqRMmL9TmpCKsrxEaowd3Rni1d9aLjj8sBlzXsttN2FVmDyH/w18/UaGw2TdmAqzTsSC6W4nMWeNxzSgvtzJt48NmkKfEaDK+0cvuJ4MRytisC5K+kDZpOhZvlCkc8bEePfmntWdX7AF9wqiJYq4jc8Du6aOjC1Jtsp7bsCl11HPMQk9gZeHrpbgpFxm1PsWk+EwMt0GA/obz0cUjcVwZFgyCU4xj3aXSKM/BmfYudQazjW1iVz+Abomo7ilVXCmME/7H8W/cB7VN/1+F71DHRqVDy4WiwVdDln4PlQBwN2aHwedZPzV60gulvcHZld+wD+QE/DsLtZgVGw4mXRNRvBEo1mhXQ4Lx+A+UgbK0A9I37RSg6XocS4AEeOX9uD9h5YZQFNP5MTCOsN2SLBy+qsUMWqHiLeKlGedNT2t2R5LxmfEnus9ymHu6GY2lOUeM/Y/Zx2vNqreEb3Rn2A4KGUgF2DGZ8pe1cxxeLynyjB68PVufuAfdddnzilzFqmHXfaFnU3/WDIyf6LYWc+kWHGHehT6DLmtUoYr6K308sh7eI/DRGOmA1J8hRcmuGhpoS48uiurdkn0YmWD6XVIRr3JY8ZR5Y2SzpFjmAdPYyoaT/Hgw3BFj3O2wMs1Ci+hTByd4M5yN+Sgt3lOyRv9XaLDIdjcAMrTo7+rMvrh1X2Z9J5+g4C/3Bmf6a/0grF/jDrYQ8X8lMLM06mCLX8LBQ/sXnj2efHTVToAox8gEc+eCqWYm3VSRnDq1U2A08GDtkZuqhAPJjTbJTCYrGsPphCByrgW4GrVDlS5PQZ8pZxS/BgmaS6QwpZjukRg8wSlt4zGozvV+N/Ci6G1szKC0SuDMv41eA9CbMt617uIyzs975esE645/yKfNgGucXI8wz4dDRiqukB6hugduoCnDoaXjL2OnANj/wOSamiwQfnbtAAAAABJRU5ErkJggg==", 280 | "text/latex": [ 281 | "$\\displaystyle x^{2} + 5 x + 6 = 0$" 282 | ], 283 | "text/plain": [ 284 | " 2 \n", 285 | "x + 5⋅x + 6 = 0" 286 | ] 287 | }, 288 | "execution_count": 4, 289 | "metadata": {}, 290 | "output_type": "execute_result" 291 | } 292 | ], 293 | "source": [ 294 | "# Create the mathematical symbols x and the equation\n", 295 | "x = symbols('x')\n", 296 | "eq = Eq(x**2 + 5*x + 6, 0)\n", 297 | "eq" 298 | ] 299 | }, 300 | { 301 | "cell_type": "markdown", 302 | "metadata": {}, 303 | "source": [ 304 | "Now we use the `solve` function to solve the equation." 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "execution_count": 5, 310 | "metadata": {}, 311 | "outputs": [ 312 | { 313 | "data": { 314 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEwAAAAVCAYAAADsFggUAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACgElEQVRYCe2Y0VHbQBCGBZMCDCWQDgh0QDqIWzAdhMmT/Uo6gBagA0gHgQ6gA4hLyPcpOlk6WR4kc5Ymw80st7d3uv313+7qzN58Pv+eZdk5YpsuFovHf+rHXxmAjxo/exB2if2OifsPitoZgJ+cp0/tS7abwcERO4TInaA7vhzbwRQ4L4q3PaF/RS6wr820JIThTIJ0GgjL0L9hM5JN+1v0wRs4PMQr+q8BDLqR9KANaWTdflj4zv2M/WY4lKTQgvMfwTCCXnLKQxUPmI22JXLjOG6pCDOcdarkDSClHmwj6M/A8AS2SYTFw51gNwJrLVVK6vCg6gnnIdquqvaBdXEebzjMmMgsCWExCQDyJPPwR7+O54cag2Xa4vtYO/ONwp+UMBzqWLJOEZ3/RkbdCsymYvhy1vCmJkyS8lMCiCnp12c0X8kaE6uBxf4WnD9XppW2ljAWm7u/kEYOrx5taBt/JbCnIJY8dUN/UOiNTboY2ONdcbKf9fWZvi1V19ew4mW+dAFfXcvzbTXAlDRFla3vYtvijDB7FTpkz/JOVp0PeqprxQMOTL8uERow7bwHp+XiM30ZWehHSgwmFWGmXkjBqs+TYhAusRmgBiUV/2bDKX1c5CXxtQpefW0Nixf1GMfOJUYAknOOLqHaHP+hf0R6lwD36tPwaQRZ5O/R4/vhGbZG4U9CGI6uER1WQQiu9vuM+SXyjN1btZITyXhX7Q5H4rJ+xS3/usfGJITphJc37crUix2HMeusHUbfzpu+uzrd7/pAovXWkF1HV69XGZwwiLKOvfRCP8BDgxPGO88grVFcB+DiTS7Dv6hDDdl4W3/Tjv/ZIg4z/E//kFeb/gV9ueIe+TWktAAAAABJRU5ErkJggg==", 315 | "text/latex": [ 316 | "$\\displaystyle \\left[ -3, \\ -2\\right]$" 317 | ], 318 | "text/plain": [ 319 | "[-3, -2]" 320 | ] 321 | }, 322 | "execution_count": 5, 323 | "metadata": {}, 324 | "output_type": "execute_result" 325 | } 326 | ], 327 | "source": [ 328 | "# Verify the solution\n", 329 | "solve(eq, x)" 330 | ] 331 | }, 332 | { 333 | "cell_type": "markdown", 334 | "metadata": {}, 335 | "source": [ 336 | "The solution is returned as a `Python` list object with the elements $-3$ and $-2$, confirming the results $x=-3$ or $x=-2$." 337 | ] 338 | }, 339 | { 340 | "cell_type": "markdown", 341 | "metadata": {}, 342 | "source": [ 343 | "__Homework 7.4.1__ Solve the quadratic equation $x^2 + 7x + 12 = 0$." 344 | ] 345 | }, 346 | { 347 | "cell_type": "markdown", 348 | "metadata": {}, 349 | "source": [ 350 | "__Problem 7.4.2__ Solve the quadratic equation $4x^2 + 5x - 6 = 0$." 351 | ] 352 | }, 353 | { 354 | "cell_type": "markdown", 355 | "metadata": {}, 356 | "source": [ 357 | "We have a few options to start with. We can have $(4x \\quad)(x \\quad)=0$ or $(2x \\quad)(2 x \\quad)$. Both will lead to $4x^{2}$ as the first term. We also have options for $-6$. These are $6 \\times (-1)$ or $(-1) \\times 6$ or $(-2) \\times 3$ or $3 \\times (-2)$ or $(-3) \\times 2$ or $2 \\times (-3)$. We have to find a combination of these such that the _middle_ $x$ _term_ sums to $+5$. We see the solution in __Equation 7.4.5__." 358 | ] 359 | }, 360 | { 361 | "cell_type": "markdown", 362 | "metadata": {}, 363 | "source": [ 364 | "$$\n", 365 | "\\begin{align*}\n", 366 | "&4x^2 + 5x - 6 = 0\\\\ \\\\\n", 367 | "&\\left( 4x - 3 \\right)\\left( x + 2 \\right) = 0 \\\\ \\\\\n", 368 | "&4x - 3 = 0 \\quad \\text{or} \\quad x + 2 = 0 \\\\ \\\\\n", 369 | "&x = \\frac{3}{4} \\quad \\text{or} \\quad x = -2\n", 370 | "\\end{align*}\n", 371 | "\\tag{Equation 7.4.5}\n", 372 | "$$" 373 | ] 374 | }, 375 | { 376 | "cell_type": "markdown", 377 | "metadata": {}, 378 | "source": [ 379 | "We can verify the results by completing the multiplication $(4x-3)(x+2)$. The result is indeed $4x^2 + 5x - 6 = 0$. We can also substitute the solutions into the original equatiion. We start with $x=\\frac{3}{4}$ in __Equation 7.4.6__." 380 | ] 381 | }, 382 | { 383 | "cell_type": "markdown", 384 | "metadata": {}, 385 | "source": [ 386 | "$$\n", 387 | "\\begin{align*}\n", 388 | "&4x^2 + 5x - 6 = 0 \\\\ \\\\\n", 389 | "&4\\left( \\frac{3}{4} \\right)^2 + 5\\left( \\frac{3}{4} \\right) - 6 = 0 \\\\ \\\\\n", 390 | "&4\\left( \\frac{9}{16} \\right) + \\frac{15}{4} - 6 = 0 \\\\ \\\\\n", 391 | "&\\frac{9}{4} + \\frac{15}{4} - 6 = 0 \\\\ \\\\\n", 392 | "&\\frac{24}{4} - 6 = 0 \\\\ \\\\\n", 393 | "&6 - 6 = 0 \\\\ \\\\\n", 394 | "&0 = 0\n", 395 | "\\end{align*}\n", 396 | "\\tag{Equation 7.4.6}\n", 397 | "$$" 398 | ] 399 | }, 400 | { 401 | "cell_type": "markdown", 402 | "metadata": {}, 403 | "source": [ 404 | "Now we substiture $x=-2$ in __Equation 7.4.7__." 405 | ] 406 | }, 407 | { 408 | "cell_type": "markdown", 409 | "metadata": {}, 410 | "source": [ 411 | "$$\n", 412 | "\\begin{align*}\n", 413 | "&4x^2 + 5x - 6 = 0 \\\\ \\\\\n", 414 | "&4\\left( -2 \\right)^2 + 5\\left( -2 \\right) - 6 = 0 \\\\ \\\\\n", 415 | "&4\\left( 4 \\right) - 10 - 6 = 0 \\\\ \\\\\n", 416 | "&16 - 10 - 6 = 0 \\\\ \\\\\n", 417 | "&6 - 6 = 0 \\\\ \\\\\n", 418 | "&0 = 0\n", 419 | "\\end{align*}\n", 420 | "\\tag{Equation 7.4.7}\n", 421 | "$$" 422 | ] 423 | }, 424 | { 425 | "cell_type": "markdown", 426 | "metadata": {}, 427 | "source": [ 428 | "Finally, we use `sympy` to verify the solutions." 429 | ] 430 | }, 431 | { 432 | "cell_type": "code", 433 | "execution_count": 6, 434 | "metadata": {}, 435 | "outputs": [ 436 | { 437 | "data": { 438 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI4AAAAVCAYAAACQXNaIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAENklEQVRoBe2Z7VEbMRCGDUMBDlQQ0gEhFQAd5KMCSAfJ8Av+MaQDoIJAOoBUwEcH0EESOiDPI04a+Thj7mzOB+OdkaVbfdy7e6vdlTx3d3fXq0u7u7t95mwX85aLehP+bd21ZuNfpgYWGsLex0i+xrm0D2hfUt5F3qx+3RqYbyjeFsayns3dp70MbyXjzZqvWANNDUdvc/GK9TITbZQGzHHGLTs7O/uU63HXaTqfd6+U58LrU5bL/Nnz+N9bHTbNcZI9FuHpI4z3idl+4zc4TNivilfblqaJ6R7BE3/Bb7jP6Se8KE/Ob62dYfrDS81fzW1vBDCW4bCIJyoFfk97mieqvwoDmWMp2C/K3pQxAWE0FTo8YeR32mfOoPbZMrXDBhg87KhDdSkmN+Ml9QblprHhMFmjUdiNYmGfey5qXYeYY6Jtcn1YZ1429oq5n7Ln1poTwK6B6F2C0RTA/Ui19TgpocGyxVp96mA0rkv7tnj2BL3RyHBYQCNxAQ0nnqRMmL9TmpCKsrxEaowd3Rni1d9aLjj8sBlzXsttN2FVmDyH/w18/UaGw2TdmAqzTsSC6W4nMWeNxzSgvtzJt48NmkKfEaDK+0cvuJ4MRytisC5K+kDZpOhZvlCkc8bEePfmntWdX7AF9wqiJYq4jc8Du6aOjC1Jtsp7bsCl11HPMQk9gZeHrpbgpFxm1PsWk+EwMt0GA/obz0cUjcVwZFgyCU4xj3aXSKM/BmfYudQazjW1iVz+Abomo7ilVXCmME/7H8W/cB7VN/1+F71DHRqVDy4WiwVdDln4PlQBwN2aHwedZPzV60gulvcHZld+wD+QE/DsLtZgVGw4mXRNRvBEo1mhXQ4Lx+A+UgbK0A9I37RSg6XocS4AEeOX9uD9h5YZQFNP5MTCOsN2SLBy+qsUMWqHiLeKlGedNT2t2R5LxmfEnus9ymHu6GY2lOUeM/Y/Zx2vNqreEb3Rn2A4KGUgF2DGZ8pe1cxxeLynyjB68PVufuAfdddnzilzFqmHXfaFnU3/WDIyf6LYWc+kWHGHehT6DLmtUoYr6K308sh7eI/DRGOmA1J8hRcmuGhpoS48uiurdkn0YmWD6XVIRr3JY8ZR5Y2SzpFjmAdPYyoaT/Hgw3BFj3O2wMs1Ci+hTByd4M5yN+Sgt3lOyRv9XaLDIdjcAMrTo7+rMvrh1X2Z9J5+g4C/3Bmf6a/0grF/jDrYQ8X8lMLM06mCLX8LBQ/sXnj2efHTVToAox8gEc+eCqWYm3VSRnDq1U2A08GDtkZuqhAPJjTbJTCYrGsPphCByrgW4GrVDlS5PQZ8pZxS/BgmaS6QwpZjukRg8wSlt4zGozvV+N/Ci6G1szKC0SuDMv41eA9CbMt617uIyzs975esE645/yKfNgGucXI8wz4dDRiqukB6hugduoCnDoaXjL2OnANj/wOSamiwQfnbtAAAAABJRU5ErkJggg==", 439 | "text/latex": [ 440 | "$\\displaystyle x^{2} + 5 x + 6 = 0$" 441 | ], 442 | "text/plain": [ 443 | " 2 \n", 444 | "x + 5⋅x + 6 = 0" 445 | ] 446 | }, 447 | "execution_count": 6, 448 | "metadata": {}, 449 | "output_type": "execute_result" 450 | } 451 | ], 452 | "source": [ 453 | "# Create the equation and assign it to the variable eq\n", 454 | "eq = Eq(x**2 + 5*x + 6, 0)\n", 455 | "eq" 456 | ] 457 | }, 458 | { 459 | "cell_type": "code", 460 | "execution_count": 7, 461 | "metadata": {}, 462 | "outputs": [ 463 | { 464 | "data": { 465 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEwAAAAVCAYAAADsFggUAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACgElEQVRYCe2Y0VHbQBCGBZMCDCWQDgh0QDqIWzAdhMmT/Uo6gBagA0gHgQ6gA4hLyPcpOlk6WR4kc5Ymw80st7d3uv313+7qzN58Pv+eZdk5YpsuFovHf+rHXxmAjxo/exB2if2OifsPitoZgJ+cp0/tS7abwcERO4TInaA7vhzbwRQ4L4q3PaF/RS6wr820JIThTIJ0GgjL0L9hM5JN+1v0wRs4PMQr+q8BDLqR9KANaWTdflj4zv2M/WY4lKTQgvMfwTCCXnLKQxUPmI22JXLjOG6pCDOcdarkDSClHmwj6M/A8AS2SYTFw51gNwJrLVVK6vCg6gnnIdquqvaBdXEebzjMmMgsCWExCQDyJPPwR7+O54cag2Xa4vtYO/ONwp+UMBzqWLJOEZ3/RkbdCsymYvhy1vCmJkyS8lMCiCnp12c0X8kaE6uBxf4WnD9XppW2ljAWm7u/kEYOrx5taBt/JbCnIJY8dUN/UOiNTboY2ONdcbKf9fWZvi1V19ew4mW+dAFfXcvzbTXAlDRFla3vYtvijDB7FTpkz/JOVp0PeqprxQMOTL8uERow7bwHp+XiM30ZWehHSgwmFWGmXkjBqs+TYhAusRmgBiUV/2bDKX1c5CXxtQpefW0Nixf1GMfOJUYAknOOLqHaHP+hf0R6lwD36tPwaQRZ5O/R4/vhGbZG4U9CGI6uER1WQQiu9vuM+SXyjN1btZITyXhX7Q5H4rJ+xS3/usfGJITphJc37crUix2HMeusHUbfzpu+uzrd7/pAovXWkF1HV69XGZwwiLKOvfRCP8BDgxPGO88grVFcB+DiTS7Dv6hDDdl4W3/Tjv/ZIg4z/E//kFeb/gV9ueIe+TWktAAAAABJRU5ErkJggg==", 466 | "text/latex": [ 467 | "$\\displaystyle \\left[ -3, \\ -2\\right]$" 468 | ], 469 | "text/plain": [ 470 | "[-3, -2]" 471 | ] 472 | }, 473 | "execution_count": 7, 474 | "metadata": {}, 475 | "output_type": "execute_result" 476 | } 477 | ], 478 | "source": [ 479 | "# Solve the equation\n", 480 | "solve(eq, x)" 481 | ] 482 | }, 483 | { 484 | "cell_type": "markdown", 485 | "metadata": {}, 486 | "source": [ 487 | "The solutions are confirmed by `sympy`." 488 | ] 489 | }, 490 | { 491 | "cell_type": "markdown", 492 | "metadata": {}, 493 | "source": [ 494 | "__Homework 7.4.2__ Solve the quadratic equation $8x^2 - 34x + 8 = 0$." 495 | ] 496 | }, 497 | { 498 | "cell_type": "markdown", 499 | "metadata": {}, 500 | "source": [ 501 | "Some problems only require the _extraction_ of a common factor. We see this in __Problem 7.4.3__." 502 | ] 503 | }, 504 | { 505 | "cell_type": "markdown", 506 | "metadata": {}, 507 | "source": [ 508 | "__Problem 7.4.3__ Solve the quadratic equation $x^2 - 4x = 0$." 509 | ] 510 | }, 511 | { 512 | "cell_type": "markdown", 513 | "metadata": {}, 514 | "source": [ 515 | "We note that $c=0$. We can factor out $x$ from the left-hand side of the equation. This is shown in __Equation 7.4.8__." 516 | ] 517 | }, 518 | { 519 | "cell_type": "markdown", 520 | "metadata": {}, 521 | "source": [ 522 | "$$\n", 523 | "\\begin{align*}\n", 524 | "&x^2 - 4x = 0 \\\\ \\\\\n", 525 | "&x\\left( x - 4 \\right) = 0 \\\\ \\\\\n", 526 | "&x = 0 \\quad \\text{or} \\quad x - 4 = 0 \\\\ \\\\\n", 527 | "&x = 0 \\quad \\text{or} \\quad x = 4\n", 528 | "\\end{align*}\n", 529 | "\\tag{Equation 7.4.8}\n", 530 | "$$" 531 | ] 532 | }, 533 | { 534 | "cell_type": "markdown", 535 | "metadata": {}, 536 | "source": [ 537 | "We can substitute to verify the results. Instead, we will only confirm the solutions using `sympy`." 538 | ] 539 | }, 540 | { 541 | "cell_type": "code", 542 | "execution_count": 8, 543 | "metadata": {}, 544 | "outputs": [ 545 | { 546 | "data": { 547 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAACwAAAAVCAYAAAA98QxkAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACEElEQVRIDc2X7VECQQyGD8cCGO0AOsChAi1BtAKhA/kJf7EDbUE70A4YKYEOBErweYHs3Ef27oBjhswsyWY3ybu72c3Rmkwmr0mSjGiiwXQ6XezEy/gFTwZfC8AzoH0z8HMZEH0U4NvivPaHd9r9JHX+aF3aDN1SinMR/nv4HsHt1DOhrjK9VAeDX7pz+Jj2hjym6SQ6qWnnED9xehNz7AIG1BCDNvzLDJE3yOq/m65pTgzlaym5gLEY0LzLN0f/gON2qdcjBvGpVNCmqEUpBvgBi5VjZfmr8abpGdAfVU4LgGvuXjTHqgJ648RUKtRKtQJgDA1M2dE0lhKA7RBzA7fT89YUdB7gMFgi3JaMHTqkJ6wyFcypB9jLXZtvu693+WQCqF6jWqlgwQqAcWKp4B276WodnwXxOHGUCno6D/IVq3Qq03KYJ9vhJsq4/PcBrEKRph6dzl6/hKtgBYoBlhPV7jzdoVjgxE4hQdYuhX7eINbHRosuLBz9Wnq4akGBCimhGUzWJVjBH80CWenwRHvJ6daMqYw3RYqj5lJshzVZu6mPnT5cl0z8nn6ogMj2HGmXj9ppfG4Je10+S0NVU52yvmX0HRMoCpiJOmb3iylYIzCvSwsnkR47RMZHZSz5c1PikED7ubo8WuDZ6WTAAFW+NfIu11ntyYAJMgR0Js/qBD52jv1Fshy85P90qgGDf1wTpx4Bk1puAAAAAElFTkSuQmCC", 548 | "text/latex": [ 549 | "$\\displaystyle \\left[ 0, \\ 4\\right]$" 550 | ], 551 | "text/plain": [ 552 | "[0, 4]" 553 | ] 554 | }, 555 | "execution_count": 8, 556 | "metadata": {}, 557 | "output_type": "execute_result" 558 | } 559 | ], 560 | "source": [ 561 | "# Verify the solution\n", 562 | "solve(Eq(x**2 - 4 * x, 0), x)" 563 | ] 564 | }, 565 | { 566 | "cell_type": "markdown", 567 | "metadata": {}, 568 | "source": [ 569 | "__Homework 7.4.3__ Solve the quadratic equation $x^2 - 5x = 0$." 570 | ] 571 | }, 572 | { 573 | "cell_type": "markdown", 574 | "metadata": {}, 575 | "source": [ 576 | "## 7.5 Completing the square" 577 | ] 578 | }, 579 | { 580 | "cell_type": "markdown", 581 | "metadata": {}, 582 | "source": [ 583 | "Many quadratic equations can be solved by factoring. However, some quadratic equations are not easily factored. We can solve these equations by _completing the square_." 584 | ] 585 | }, 586 | { 587 | "cell_type": "markdown", 588 | "metadata": {}, 589 | "source": [ 590 | "The technique of completing the square is used to solve quadratic equations by introducing new terms to the equation. These new terms make it easier to factor the quadratic equation." 591 | ] 592 | }, 593 | { 594 | "cell_type": "markdown", 595 | "metadata": {}, 596 | "source": [ 597 | "The image below visualizes the process of completing the square." 598 | ] 599 | }, 600 | { 601 | "cell_type": "markdown", 602 | "metadata": {}, 603 | "source": [ 604 | "__Equation 7.5.1__ shows the steps that we take to complete the square, following from the visualization above." 605 | ] 606 | }, 607 | { 608 | "cell_type": "markdown", 609 | "metadata": {}, 610 | "source": [ 611 | "$$\n", 612 | "\\begin{align*}\n", 613 | "&ax^{2}+b^{x}+c=0 \\\\ \\\\\n", 614 | "&x^{2}+\\frac{b}{a}x=-\\frac{c}{a} \\\\ \\\\\n", 615 | "&x^{2}+\\frac{b}{a}x+\\left( \\frac{b}{2a} \\right)^{2}=-\\frac{c}{a}+\\left( \\frac{b}{2a} \\right)^{2} \\\\ \\\\\n", 616 | "&\\left( x+\\frac{b}{2a} \\right)^{2}=-\\frac{c}{a}+\\left( \\frac{b}{2a} \\right)^{2} \\\\ \\\\\n", 617 | "&x + \\frac{b}{2a} = \\pm \\sqrt{-\\frac{c}{a}+\\left( \\frac{b}{2a} \\right)^{2}} \\\\ \\\\\n", 618 | "&x = - \\frac{b}{2a} \\pm \\sqrt{-\\frac{c}{a}+\\left( \\frac{b}{2a} \\right)^{2}} \\\\ \\\\\n", 619 | "\\end{align*}\n", 620 | "\\tag{Equation 7.5.1}\n", 621 | "$$" 622 | ] 623 | }, 624 | { 625 | "cell_type": "markdown", 626 | "metadata": {}, 627 | "source": [ 628 | "__Problem 7.5.1__ Solve the quadratic equation $x^{2} + 6x + 7 = 0$." 629 | ] 630 | }, 631 | { 632 | "cell_type": "markdown", 633 | "metadata": {}, 634 | "source": [ 635 | "We follow the outline in __Equation 7.5.1__ and show the solution in __Equation 7.5.2__." 636 | ] 637 | }, 638 | { 639 | "cell_type": "markdown", 640 | "metadata": {}, 641 | "source": [ 642 | "$$\n", 643 | "\\begin{align*}\n", 644 | "&x^{2}+6x=-7 \\\\ \\\\\n", 645 | "&x^{2}+6x+\\left( \\frac{6}{2} \\right)^{2}=-7+\\left( \\frac{6}{2} \\right)^{2} \\\\ \\\\\n", 646 | "&x^{2}+6x+9=-7+9 \\\\ \\\\\n", 647 | "&\\left( x+3 \\right)^{2}=2 \\\\ \\\\\n", 648 | "&x+3=\\pm \\sqrt{2} \\\\ \\\\\n", 649 | "&x=-3\\pm \\sqrt{2}\n", 650 | "\\end{align*}\n", 651 | "\\tag{Equation 7.5.2}\n", 652 | "$$" 653 | ] 654 | }, 655 | { 656 | "cell_type": "markdown", 657 | "metadata": {}, 658 | "source": [ 659 | "We can verify the solutions by substituting them into the original equation. We start with $x=-3+\\sqrt{2}$ in __Equation 7.5.3__." 660 | ] 661 | }, 662 | { 663 | "cell_type": "markdown", 664 | "metadata": {}, 665 | "source": [ 666 | "$$\n", 667 | "\\begin{align*}\n", 668 | "&\\left( -3+\\sqrt{2} \\right)^{2}+6\\left( -3+\\sqrt{2} \\right)+7=0 \\\\ \\\\\n", 669 | "&9-6\\sqrt{2}+2+6\\sqrt{2}+7=0 \\\\ \\\\\n", 670 | "&18-18=0 \\\\ \\\\\n", 671 | "&0=0\n", 672 | "\\end{align*}\n", 673 | "\\tag{Equation 7.5.3}\n", 674 | "$$" 675 | ] 676 | }, 677 | { 678 | "cell_type": "markdown", 679 | "metadata": {}, 680 | "source": [ 681 | "We continue with $x=-3-\\sqrt{2}$ in __Equation 7.5.4__." 682 | ] 683 | }, 684 | { 685 | "cell_type": "markdown", 686 | "metadata": {}, 687 | "source": [ 688 | "$$\n", 689 | "\\begin{align*}\n", 690 | "&\\left( -3-\\sqrt{2} \\right)^{2}+6\\left( -3-\\sqrt{2} \\right)+7=0 \\\\ \\\\\n", 691 | "&9+6\\sqrt{2}+2-6\\sqrt{2}+7=0 \\\\ \\\\\n", 692 | "&18-18=0 \\\\ \\\\\n", 693 | "&0=0\n", 694 | "\\end{align*}\n", 695 | "\\tag{Equation 7.5.4}\n", 696 | "$$" 697 | ] 698 | }, 699 | { 700 | "cell_type": "markdown", 701 | "metadata": {}, 702 | "source": [ 703 | "__Homework 7.5.1__ Solve the quadratic equation $x^{2} + 14x + 24 = 0$ by completing the square." 704 | ] 705 | }, 706 | { 707 | "cell_type": "markdown", 708 | "metadata": {}, 709 | "source": [ 710 | "__Problem 7.5.2__ Solve the quadratic equation $5x^{2} - 4x - 2 = 0$." 711 | ] 712 | }, 713 | { 714 | "cell_type": "markdown", 715 | "metadata": {}, 716 | "source": [ 717 | "The solution is shown in __Equation 7.5.5__." 718 | ] 719 | }, 720 | { 721 | "cell_type": "markdown", 722 | "metadata": {}, 723 | "source": [ 724 | "$$\n", 725 | "\\begin{align*}\n", 726 | "&5x^{2}-4x=-2 \\\\ \\\\\n", 727 | "&x^{2} + \\left( \\frac{-4}{5} \\right) x = \\frac{2}{5} \\\\ \\\\\n", 728 | "&x^{2} + \\left( \\frac{-4}{5} \\right) x + \\left( \\frac{-4}{10} \\right)^{2} = \\frac{2}{5} + \\left( \\frac{-4}{10} \\right)^{2} \\\\ \\\\\n", 729 | "&x^{2} + \\left( \\frac{-4}{5} \\right) x + \\left( \\frac{-2}{5} \\right)^{2} = \\frac{2}{5} + \\left( \\frac{-2}{5} \\right)^{2} \\\\ \\\\\n", 730 | "&\\left( x - \\frac{2}{5} \\right) = \\frac{2}{5} + \\frac{4}{25} \\\\ \\\\\n", 731 | "&x - \\frac{2}{5} = \\pm \\sqrt{\\frac{2}{5} + \\frac{4}{25}} \\\\ \\\\\n", 732 | "&x = \\frac{2}{5} \\ pm \\sqrt{\\frac{10 + 4}{25}} \\\\ \\\\\n", 733 | "&x = \\frac{2}{5} \\pm \\sqrt{\\frac{14}{25}} \\\\ \\\\\n", 734 | "&x = \\frac{2}{5} \\pm \\frac{\\sqrt{14}}{5}\n", 735 | "\\end{align*}\n", 736 | "\\tag{Equation 7.5.5}\n", 737 | "$$" 738 | ] 739 | }, 740 | { 741 | "cell_type": "markdown", 742 | "metadata": {}, 743 | "source": [ 744 | "__Homework 7.5.2__ Solve the quadratic equation $4x^{2} - 8x - 32 = 0$ by completing the square." 745 | ] 746 | }, 747 | { 748 | "cell_type": "markdown", 749 | "metadata": {}, 750 | "source": [ 751 | "## 7.6 Solving quadratic equations using the quadratic formula" 752 | ] 753 | }, 754 | { 755 | "cell_type": "markdown", 756 | "metadata": {}, 757 | "source": [ 758 | "There is a simple formula to solve quadratic equations. This is the __quadratic formula__. We see this in __Equation 7.6.1__ where we use a technique called completing the square, where $a \\ne 0$." 759 | ] 760 | }, 761 | { 762 | "cell_type": "markdown", 763 | "metadata": {}, 764 | "source": [ 765 | "$$\n", 766 | "\\begin{align*}\n", 767 | "&ax^2 + bx + c = 0 \\\\ \\\\\n", 768 | "&x^2 + \\frac{b}{a}x + \\left( \\frac{b}{2a} \\right)^{2} + \\frac{c}{a} = \\left( \\frac{b}{2a} \\right)^{2} \\\\ \\\\\n", 769 | "&\\left( x + \\frac{b}{2a}\\right) \\left( x + \\frac{b}{2a} \\right) + \\frac{c}{a} = \\left( \\frac{b}{2a} \\right)^{2} \\\\ \\\\\n", 770 | "&\\left( x + \\frac{b}{2a}\\right)^{2} + \\frac{c}{a} = \\left( \\frac{b}{2a} \\right)^{2} \\\\ \\\\\n", 771 | "&\\left( x + \\frac{b}{2a}\\right)^{2} = \\left( \\frac{b}{2a} \\right)^{2} - \\frac{c}{a} \\\\ \\\\\n", 772 | "&\\left( x + \\frac{b}{2a}\\right)^{2} = \\frac{b^{2}}{4a^{2}} - \\frac{c}{a} \\\\ \\\\\n", 773 | "&\\left( x + \\frac{b}{2a}\\right)^{2} = \\frac{b^{2}}{4a^{2}} - \\frac{4ac}{4a^{2}} \\\\ \\\\\n", 774 | "&x + \\frac{b}{2a} = \\pm \\sqrt{\\frac{b^{2} - 4ac}{4a^{2}}} \\\\ \\\\\n", 775 | "&x = - \\frac{b}{2a} \\pm \\frac{\\sqrt{b^2 - 4ac}}{2a} \\\\ \\\\\n", 776 | "&x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\n", 777 | "\\end{align*}\n", 778 | "\\tag{Equation 7.6.1}\n", 779 | "$$" 780 | ] 781 | }, 782 | { 783 | "cell_type": "markdown", 784 | "metadata": {}, 785 | "source": [ 786 | "We use $\\pm$ to indicate that we have two solutions. One in which we add and one in which we subtract. Remember that the square root of a number such as $4$ is $\\sqrt{4} = \\pm 2$ since $2^{2}=4$ and $(-2)^{2}=4$." 787 | ] 788 | }, 789 | { 790 | "cell_type": "markdown", 791 | "metadata": {}, 792 | "source": [ 793 | "__Problem 7.6.1__ Solve the quadratic equation $2x^2 + 7x -4 = 0$ using the quadratic formula." 794 | ] 795 | }, 796 | { 797 | "cell_type": "markdown", 798 | "metadata": {}, 799 | "source": [ 800 | "We have that $a=2$, $b=7$, and $c = -4$. This would be a difficult problem to solve using number that multiply to $2$ and to $-4$ such that the middle term sums to $+7$. Instead, we substitute our values for $a$, $b$, and $c$ into the quadratic formula in __Equation 7.6.1__ and show the solutions in __Equation 7.6.2__." 801 | ] 802 | }, 803 | { 804 | "cell_type": "markdown", 805 | "metadata": {}, 806 | "source": [ 807 | "$$\n", 808 | "\\begin{align*}\n", 809 | "&x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a} \\\\ \\\\\n", 810 | "&x = \\frac{-7 \\pm \\sqrt{7^2 - 4 \\times 2 \\times \\left( -4 \\right)}}{2 \\times 2} \\\\ \\\\\n", 811 | "&x = \\frac{-7 \\pm \\sqrt{49 + 32}}{4} \\\\ \\\\\n", 812 | "&x = \\frac{-7 \\pm \\sqrt{81}}{4} \\\\ \\\\\n", 813 | "&x = \\frac{-7 \\pm 9}{4} \\\\ \\\\\n", 814 | "&x = \\frac{-7 + 9}{4} \\quad \\text{or} \\quad x = \\frac{-7 - 9}{4} \\\\ \\\\\n", 815 | "&x = \\frac{2}{4} \\quad \\text{or} \\quad x = \\frac{-16}{4} \\\\ \\\\\n", 816 | "&x = \\frac{1}{2} \\quad \\text{or} \\quad x = -4\n", 817 | "\\end{align*}\n", 818 | "\\tag{Equation 7.6.2}\n", 819 | "$$" 820 | ] 821 | }, 822 | { 823 | "cell_type": "markdown", 824 | "metadata": {}, 825 | "source": [ 826 | "We can once again verify the results by substituting the solutions into the original equation. Below, we simply use `sympy` to verify the solutions." 827 | ] 828 | }, 829 | { 830 | "cell_type": "code", 831 | "execution_count": 9, 832 | "metadata": {}, 833 | "outputs": [ 834 | { 835 | "data": { 836 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEYAAAAzCAYAAAAqwX72AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADP0lEQVRoBe2b4XHTMBTHE44BemWDdAMKG4QNmmODdgP6MfkKGxRGCBu0jFA2aDeAdgP4/Y3ds4WfLDuJ4ijSnU7ysyXr/fL0pCe30+VyeTJpSavV6rlFnJwIPVv1f4Wm9+QnJ39OjoCt0NrRXSzWUyzmgcoV5O7stsdzBw6XaLt4nbLKKPkW/WQR59R7uYbkwABAPuMb+Tf5HXlG7p1SBCPLWIgEkD5RyGp6JznfnFoIZDAtUCTKYDIYg4AhzhaTwRgEDHG2mAzGIGCIs8UcKZg3pd6nhv6mOLmQQJoSCihwVJr/KyZrZI/Ubym/ljJvER0MA1PsomOOK+/INrhJ30WstEEXe9n56tfsbdqbKDmkbVTnyy+paPcgUjQw5RTSkUCvA6N9UYwGBgU/AifI8e0LRv29UcCUU+im/uKx13cOBigzIDxTark8mLRzMJDQ0nwwU6j65bz7GBTSwfIPssrQtKDdTz1MqU8R0aYQ7/sTOkienfqe7QKjFeTc14F1jxdrCp1QRptCXcpaY22Te8G0NeghE5j3DLbanldNtfOdlfJHyuvqxpjKnYFBYX3Z/O/rJnJ9Ar2jbGzbuZZ1jWaPE8P5uoYgf9XwWYKC7IlS39FHkaKBQekb8m2p9Zy6It4iRKCUpcgXyWoa0PZFaWdTyVUIhb3RNPfPyBduuyHX9CP/VvkufabV59pr5MVqGdJnNIsJGQzPyFnLeganEoqsszjaoNSqKiD31OehHY8GDIPWFPoVOnDPc/rbnoZ10resR8DdFdLsZjRgGOElCnwxRxp+Q1bxUIKut9IKKR+madaZRgNmS1CksABof2RNSVlmZ4rmfDtHsqUHANLYH9W61cZywv0gBzwai6kpsPUqMIrdNh1XK1XnO44CDBTkdL8DKNiHJQ8GGIru5XOsKdZqPUmDAYaOPU4pP7Rq7xEmCwYY2kVrN/1iKdQV1c88PF5uJQkG5eVstYt2na1gKTzoTCku17IIOVsdbbinhwpegxxwcmAAoghecORf3BS0h1Gj5MBgEWcujSHXSfqYISDcNhmMS6S8zmAMMJWP0freiDq5tqJTo6vDFLt6o0XBobIYLWv1f+Y65n/kKnT/C6S55Tk8SG1TAAAAAElFTkSuQmCC", 837 | "text/latex": [ 838 | "$\\displaystyle \\left[ -4, \\ \\frac{1}{2}\\right]$" 839 | ], 840 | "text/plain": [ 841 | "[-4, 1/2]" 842 | ] 843 | }, 844 | "execution_count": 9, 845 | "metadata": {}, 846 | "output_type": "execute_result" 847 | } 848 | ], 849 | "source": [ 850 | "# Verify the solution\n", 851 | "solve(Eq(2 * x**2 + 7 * x - 4, 0), x)" 852 | ] 853 | }, 854 | { 855 | "cell_type": "markdown", 856 | "metadata": {}, 857 | "source": [ 858 | "__Homework 7.6.1__ Solve the quadratic equation $x^2 - 6x + 7 = 0$ using the quadratic formula." 859 | ] 860 | }, 861 | { 862 | "cell_type": "markdown", 863 | "metadata": {}, 864 | "source": [ 865 | "__Problem 7.6.2__ Solve the quadratic equation $2x^2 + 8x + 7 = 0$ using the quadratic formula." 866 | ] 867 | }, 868 | { 869 | "cell_type": "markdown", 870 | "metadata": {}, 871 | "source": [ 872 | "The solution follows in __Equation 7.6.3__ by using substitution into the quadratic formula." 873 | ] 874 | }, 875 | { 876 | "cell_type": "markdown", 877 | "metadata": {}, 878 | "source": [ 879 | "$$\n", 880 | "\\begin{align*}\n", 881 | "&x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a} \\\\ \\\\\n", 882 | "&x = \\frac{-8 \\pm \\sqrt{8^2 - 4 \\times 2 \\times 7}}{2 \\times 2} \\\\ \\\\\n", 883 | "&x = \\frac{-8 \\pm \\sqrt{64 - 56}}{4} \\\\ \\\\\n", 884 | "&x = \\frac{-8 \\pm \\sqrt{8}}{4} \\\\ \\\\\n", 885 | "&x = \\frac{-8 \\pm 2\\sqrt{2}}{4} \\\\ \\\\\n", 886 | "&x = \\frac{-8 + 2\\sqrt{2}}{4} \\quad \\text{or} \\quad x = \\frac{-8 - 2\\sqrt{2}}{4} \\\\ \\\\\n", 887 | "&x = \\frac{-4 + \\sqrt{2}}{2} \\quad \\text{or} \\quad x = \\frac{-4 - \\sqrt{2}}{2}\n", 888 | "\\end{align*}\n", 889 | "\\tag{Equation 7.6.3}\n", 890 | "$$" 891 | ] 892 | }, 893 | { 894 | "cell_type": "markdown", 895 | "metadata": {}, 896 | "source": [ 897 | "We verify the solutions using `sympy`." 898 | ] 899 | }, 900 | { 901 | "cell_type": "code", 902 | "execution_count": 10, 903 | "metadata": {}, 904 | "outputs": [ 905 | { 906 | "data": { 907 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMcAAAA/CAYAAABUxNyyAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGrklEQVR4Ae1d7XHcNhQ8ZVKAohLkDmylgsgdWJMKZHcQT35J/zJJB3YLcQdxOpDcQdxBbHWQ7J5BDgmCOIAEQIJczHB4AB6+dvEIPPBROru7u7s+HA5/4bLD5/v7+2d2ouJCYEsIYI4/YjzPHWO6+b6T+LLzmz+/WHFFhcAWEbjFoC6sgR0Xi1Y5oEEfLQFFhcDmEcC8/2QPEmlPTPvOzlBcCAiBbwi0K4cACUcATxbuUX/G9UtoKZQ5C5WVXDwChhPaD0EhhA8pRxCUA6HfkfIWAL8d5ChhKQTIyQtwMt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⎢-2 - ──, -2 + ──⎥\n", 914 | "⎣ 2 2 ⎦" 915 | ] 916 | }, 917 | "execution_count": 10, 918 | "metadata": {}, 919 | "output_type": "execute_result" 920 | } 921 | ], 922 | "source": [ 923 | "# Verify the solution\n", 924 | "solve(Eq(2 * x**2 + 8 * x + 7, 0), x)" 925 | ] 926 | }, 927 | { 928 | "cell_type": "markdown", 929 | "metadata": {}, 930 | "source": [ 931 | "Simple algebraic manipulation will show that the `sympy` results are equal to those in __Equation 7.5.3__." 932 | ] 933 | }, 934 | { 935 | "cell_type": "markdown", 936 | "metadata": {}, 937 | "source": [ 938 | "__Homework 7.6.2__ Solve the quadratic equation $x^2 - 5x + 3 = 0$ using the quadratic formula." 939 | ] 940 | }, 941 | { 942 | "cell_type": "markdown", 943 | "metadata": {}, 944 | "source": [ 945 | "Not all quadratics have real-valued solutions." 946 | ] 947 | }, 948 | { 949 | "cell_type": "markdown", 950 | "metadata": {}, 951 | "source": [ 952 | "## 7.7 Quadratic equations with complex roots" 953 | ] 954 | }, 955 | { 956 | "cell_type": "markdown", 957 | "metadata": {}, 958 | "source": [ 959 | "The real numbers are a subset of the complex numbers." 960 | ] 961 | }, 962 | { 963 | "cell_type": "markdown", 964 | "metadata": {}, 965 | "source": [ 966 | "__Defintion 7.7.1__ The __imaginary number__, $i$, is the number defined by $i^{2} = -1$ or then $i = \\sqrt{-1}$. " 967 | ] 968 | }, 969 | { 970 | "cell_type": "markdown", 971 | "metadata": {}, 972 | "source": [ 973 | "The imaginary number is unlike any real number in that the square of any real number is a non-negative nmumber. The imaginary number allows us to create complex numbers." 974 | ] 975 | }, 976 | { 977 | "cell_type": "markdown", 978 | "metadata": {}, 979 | "source": [ 980 | "__Definition 7.7.2__ The __complex numbers__ are the set of numbers of the form $a + b \\, i$ where $a, b \\in \\mathbb{R}$ and $i = \\sqrt{-1}$." 981 | ] 982 | }, 983 | { 984 | "cell_type": "markdown", 985 | "metadata": {}, 986 | "source": [ 987 | "We note that the real numbers are a subset of the complex numbers. That is to say that every real number is a complex number. We can write $a \\in \\mathbb{R}$ as $a + 0 \\, i \\in \\mathbb{C}$." 988 | ] 989 | }, 990 | { 991 | "cell_type": "markdown", 992 | "metadata": {}, 993 | "source": [ 994 | "The `sympy` keyword `I` is used for the imaginary number $i = \\sqrt{-1}$." 995 | ] 996 | }, 997 | { 998 | "cell_type": "code", 999 | "execution_count": 11, 1000 | "metadata": {}, 1001 | "outputs": [ 1002 | { 1003 | "data": { 1004 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAcAAAAOCAYAAADjXQYbAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAqklEQVQYGX2P3Q3CMAyETcUAsAJs0FmAEWADpD4lr2WDsgGiG8AGiBHoDN0gfBdCFIkfSyf7zpfYthCClXDO7UEnrbLP2CGNkidy/IpvL7P3b3Mqm/d+RtqCJbjDj+S8UINwgJ9Bq4aiQqzJt8jM1uQh1fHlgKFPwoZ8ejfzKRhWiPp2Th3vLLdtaPRqAC34WigRze4kEjLmbRcimK5A9UO8nKl5F4kY4p1PvIVEqHA5188AAAAASUVORK5CYII=", 1005 | "text/latex": [ 1006 | "$\\displaystyle i$" 1007 | ], 1008 | "text/plain": [ 1009 | "ⅈ" 1010 | ] 1011 | }, 1012 | "execution_count": 11, 1013 | "metadata": {}, 1014 | "output_type": "execute_result" 1015 | } 1016 | ], 1017 | "source": [ 1018 | "# Print the imaginary number i\n", 1019 | "I" 1020 | ] 1021 | }, 1022 | { 1023 | "cell_type": "code", 1024 | "execution_count": 12, 1025 | "metadata": {}, 1026 | "outputs": [ 1027 | { 1028 | "data": { 1029 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAOCAYAAAA1+Nx+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAj0lEQVQ4EWP8//8/A7VAQ0ODEdCs1UBsDGR/AJnLAiIoAUCDBID6ZwPxOyA2AWIlIIYDalgAcmkoyESgZWVACuQLOGCCs2jEGLWAYMDSPIhYoMlsL9ApoORGLAgF6jtHjGKQBaBkZkyMYnLU0DyIhpwFwtBgFIIFJyM1CjtgPIIKOBBwAWJQYgElgHtAvBsAO3sgJ/LwrLIAAAAASUVORK5CYII=", 1030 | "text/latex": [ 1031 | "$\\displaystyle -1$" 1032 | ], 1033 | "text/plain": [ 1034 | "-1" 1035 | ] 1036 | }, 1037 | "execution_count": 12, 1038 | "metadata": {}, 1039 | "output_type": "execute_result" 1040 | } 1041 | ], 1042 | "source": [ 1043 | "# Note that the square of the imaginary number i is -1\n", 1044 | "I**2" 1045 | ] 1046 | }, 1047 | { 1048 | "cell_type": "markdown", 1049 | "metadata": {}, 1050 | "source": [ 1051 | "The solutions or roots of a quadratic equation can be complex numbers. This happens when the values under the square root symbol in the quadratic formula is negative. We cannot calculate the square root of a negative number without the use of the complex numbers." 1052 | ] 1053 | }, 1054 | { 1055 | "cell_type": "markdown", 1056 | "metadata": {}, 1057 | "source": [ 1058 | "__Problem 7.7.1__ Calculate the value of the square root of $-9$." 1059 | ] 1060 | }, 1061 | { 1062 | "cell_type": "markdown", 1063 | "metadata": {}, 1064 | "source": [ 1065 | "The solution uses the imaginary number and is shown in __Equation 7.7.1__ where we make use of the fact that $i^{2}=-1$." 1066 | ] 1067 | }, 1068 | { 1069 | "cell_type": "markdown", 1070 | "metadata": {}, 1071 | "source": [ 1072 | "$$\n", 1073 | "\\begin{align*}\n", 1074 | "&\\sqrt{-9} = \\sqrt{9 \\times -1} = \\pm \\sqrt{9} \\times \\sqrt{-1} = \\pm 3i\n", 1075 | "\\end{align*}\n", 1076 | "\\tag{Equation 7.7.1}\n", 1077 | "$$" 1078 | ] 1079 | }, 1080 | { 1081 | "cell_type": "markdown", 1082 | "metadata": {}, 1083 | "source": [ 1084 | "The solutions are $0 + 3i$ and $0 - 3i$, which we abbreviate as $3i$ and $-3i$. Note that $\\left( 3i \\right) \\left( 3i \\right) = 9i^{2} = -9$ and that $ \\left( -3 i \\right) \\left( -3 i \\right) = 9i^{2} = -9$ as required." 1085 | ] 1086 | }, 1087 | { 1088 | "cell_type": "markdown", 1089 | "metadata": {}, 1090 | "source": [ 1091 | "We can verify the solution using `sympy`." 1092 | ] 1093 | }, 1094 | { 1095 | "cell_type": "code", 1096 | "execution_count": 14, 1097 | "metadata": {}, 1098 | "outputs": [ 1099 | { 1100 | "data": { 1101 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABEAAAAOCAYAAADJ7fe0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABSklEQVQoFY2T3VECUQxGF8cCtAXowNEOKEEsge0Ahrd9pQTtwIEOoAOFDqQGO1jOCTfM7jqOZiab5MvPTW7ujtq2raSmacaIOoyqukNqr8H3BesJ8AXABFnf6kExaSmgLaE/I3bIGbwNsP8xNvCbgs+R85KYodnBKoGuJNYulmJZ5Ij+XVi8IkD7X5TjeOp9N4MijiO9XsTv3ygydFNgCraGa/S39KN7d44+gQ/p6xUBfMBpgSfYET/hLq2IcQHGbOA4YFjERLki0HE8LbaD9IAPfdAMPoXGJy827askyfV5uRt0xzgVzJgX+F1FiiKeIl+g3jfHmeKPbSHt0KLXu8pODoC2rvMv8t1sLZrxWcRTwjGo8FjseHglyY5z7fEQ82Lj5XULkJBtu+YYBf/YGOw9rP6lPer8gK7NW08y6McPSLKr3RmEHvdyBntEg2MNB/NxAAAAAElFTkSuQmCC", 1102 | "text/latex": [ 1103 | "$\\displaystyle 3 i$" 1104 | ], 1105 | "text/plain": [ 1106 | "3⋅ⅈ" 1107 | ] 1108 | }, 1109 | "execution_count": 14, 1110 | "metadata": {}, 1111 | "output_type": "execute_result" 1112 | } 1113 | ], 1114 | "source": [ 1115 | "# Verify the solution\n", 1116 | "sqrt(-9)" 1117 | ] 1118 | }, 1119 | { 1120 | "cell_type": "markdown", 1121 | "metadata": {}, 1122 | "source": [ 1123 | "Note that `sympy` only returns the positive solution." 1124 | ] 1125 | }, 1126 | { 1127 | "cell_type": "markdown", 1128 | "metadata": {}, 1129 | "source": [ 1130 | "__Homework 7.7.1__ Calculate the value of the square root of $-16$." 1131 | ] 1132 | }, 1133 | { 1134 | "cell_type": "markdown", 1135 | "metadata": {}, 1136 | "source": [ 1137 | "Now that we have defined the set of complex numbers, we can solve quadratic equations that have complex roots. That is to say, quadratic equations where $b^{2} - 4ac < 0$. We see this in __Problem 7.7.2__." 1138 | ] 1139 | }, 1140 | { 1141 | "cell_type": "markdown", 1142 | "metadata": {}, 1143 | "source": [ 1144 | "__Problem 7.7.2__ Solve the quadratic equation $x^2 + 4x + 5 = 0$." 1145 | ] 1146 | }, 1147 | { 1148 | "cell_type": "markdown", 1149 | "metadata": {}, 1150 | "source": [ 1151 | "The solution follows in __Equation 7.7.2__, where we make use of the quadratic formula. Note that $b^{2} - 4ac = 4^{2} - 4(1)(5) = 16-20<0$. We must have complex roots as we will have to take the square root of a negative number." 1152 | ] 1153 | }, 1154 | { 1155 | "cell_type": "markdown", 1156 | "metadata": {}, 1157 | "source": [ 1158 | "$$\n", 1159 | "\\begin{align*}\n", 1160 | "&x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a} \\\\ \\\\\n", 1161 | "&x = \\frac{-4 \\pm \\sqrt{4^2 - 4 \\times 1 \\times 5}}{2 \\times 1} \\\\ \\\\\n", 1162 | "&x = \\frac{-4 \\pm \\sqrt{16 - 20}}{2} \\\\ \\\\\n", 1163 | "&x = \\frac{-4 \\pm \\sqrt{-4}}{2} \\\\ \\\\\n", 1164 | "&x = \\frac{-4 \\pm 2i}{2} \\\\ \\\\\n", 1165 | "&x = \\frac{-4}{2} \\pm \\frac{2i}{2} \\\\ \\\\\n", 1166 | "&x = -2 \\pm i\n", 1167 | "\\end{align*}\n", 1168 | "\\tag{Equation 7.7.2}\n", 1169 | "$$" 1170 | ] 1171 | }, 1172 | { 1173 | "cell_type": "markdown", 1174 | "metadata": {}, 1175 | "source": [ 1176 | "The roots are $x=-2+i$ and $x=-2-i$. We can verify the solutions using `sympy`." 1177 | ] 1178 | }, 1179 | { 1180 | "cell_type": "code", 1181 | "execution_count": 15, 1182 | "metadata": {}, 1183 | "outputs": [ 1184 | { 1185 | "data": { 1186 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI4AAAAVCAYAAACQXNaIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAC5ElEQVRoBe2a61HrMBCFA0MBQAmhAx4dQAeEEqADGH4l/xhuB9DCpQOgAgY6gA6AlMD5wsokvna4Nl7ZGqwZoZezZ3V2vdqIrIzH49PBYHCiShlNJpOnz27/t2fgiwH5xYKfrMhxLrV8q4W7r8f6Xs9AMQPyk5m/rBUv/3xWAENJOTNJu2rfGGu+1YgmfN6cLbUhypqK7TUpcrXqQZcRcYVxrO4IB4d51HjfA7OCTBxmWuF510dT5crFccQ04WzhjRZBRB8M9le1tSI9iDYhEramxxxw41xpf/uqx3MYtbrLuPJyHKLKs4DXcxqTR61rfpib/81DD67gPc99oxx7OQ4O8iIHIcIUFddNFQF2eC5JrlySYznMqMRQ28xrPWqCLDwcldC9pUqeda22E0W6JMmVV8T5xygiCKfhiGojvzgX/h9hk1+RU3S6pMBVNMeRpTDajRkwmuHMCA8GyNv9Eg28PlDnuSo8qkQ2of1etUouUnrrLHlXkkXOUxaWM4qbxjbccDQeaXyRgTXQaVrfilzBK8l1vmwyIVkL32ztoSfNl9kBG/0XV+43x1KE3OJgibK2H99G+IdC4E3eUH/qi1ZPelNc2V6HajmeKxf7fCFXWpvdHLseVaYA9yaZh6vPhsh1YpdzAXJUTlWrRNIoekonHDsZrtwcR0SQDO+pzSfDEPQWxRoGYo6CPoR2Ck6UFVvPxrE7KXEVuCnMccJi3VZEEFEIdXfqB2MFcdxq1gqhQUCNdhbhhIs+9J+DDI2JPu9qOfv510jUYvokwdU8MV4R51YgGIj8Jl+j5xc4hfTgmEIXHDe7x1EfffimxY12G0dYMlyJo6x4RRwu2jpV5BRZnpVXTGvkFhyh0QvY0UG/AVzGVfioV8QJ8lNqyceiR0MngtiH615cIo4TGW5i5TAcUa9uAJEFaz/uP8rrI86nUY9FduyEPbI7NQsXLgDD+V56+9ssbC8tNQb0YoXfHHMrPfoAvlpXENay4f0AAAAASUVORK5CYII=", 1187 | "text/latex": [ 1188 | "$\\displaystyle \\left[ -2 - i, \\ -2 + i\\right]$" 1189 | ], 1190 | "text/plain": [ 1191 | "[-2 - ⅈ, -2 + ⅈ]" 1192 | ] 1193 | }, 1194 | "execution_count": 15, 1195 | "metadata": {}, 1196 | "output_type": "execute_result" 1197 | } 1198 | ], 1199 | "source": [ 1200 | "# Verify the solution\n", 1201 | "solve(Eq(x**2 + 4 * x + 5, 0), x)" 1202 | ] 1203 | }, 1204 | { 1205 | "cell_type": "markdown", 1206 | "metadata": {}, 1207 | "source": [ 1208 | "__Homework 7.7.2__ Solve the quadratic equation $x^2 + 3x + 6 = 0$." 1209 | ] 1210 | }, 1211 | { 1212 | "cell_type": "code", 1213 | "execution_count": null, 1214 | "metadata": {}, 1215 | "outputs": [], 1216 | "source": [] 1217 | } 1218 | ], 1219 | "metadata": { 1220 | "kernelspec": { 1221 | "display_name": "mathematics", 1222 | "language": "python", 1223 | "name": "python3" 1224 | }, 1225 | "language_info": { 1226 | "codemirror_mode": { 1227 | "name": "ipython", 1228 | "version": 3 1229 | }, 1230 | "file_extension": ".py", 1231 | "mimetype": "text/x-python", 1232 | "name": "python", 1233 | "nbconvert_exporter": "python", 1234 | "pygments_lexer": "ipython3", 1235 | "version": "3.10.9" 1236 | }, 1237 | "orig_nbformat": 4 1238 | }, 1239 | "nbformat": 4, 1240 | "nbformat_minor": 2 1241 | } 1242 | -------------------------------------------------------------------------------- /Lecture04OrderingAndDistribution.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 4 | DISTRIBUTING" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | ">Dr J H Klopper

\n", 15 | ">Department of Biostatistics and Bioinformatics
\n", 16 | ">Milken Institute School of Public Health
\n", 17 | ">George Washington University" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "

This chapter of Algebra for Health Data Science by Dr JH Klopper is licensed under Attribution-NonCommercial-NoDerivatives 4.0 International

" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "- Watch the pencil and paper video lecture [HERE](https://youtu.be/zhjCRa5WN3k)\n", 32 | "\n", 33 | "- Watch the Python video lecture [HERE](https://youtu.be/xgwqwF9lnTw)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "## 4.1 Packages used in this chapter" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "Below we import only the functions from the `sympy` package that are used in this chapter." 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 1, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "from sympy import init_printing, symbols, Rational, sqrt, I" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "We call the `init_printing` function to make the create mathematical notation output from the `sympy` code." 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 2, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "init_printing()" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## 4.2 Introduction" 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": {}, 85 | "source": [ 86 | "In chapter 1 we considered the order of arithmetic operations. In this chapter we build on that knowledge and consider how constants and variables distribute." 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "As a reminder, we list the order of arithmetical operations below. For two operations on the same line, we perform the operation on the left first." 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "1. Parenthesis\n", 101 | "2. Powers and exponents\n", 102 | "3. Multiplication and division\n", 103 | "4. Addition and subtraction" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "metadata": {}, 109 | "source": [ 110 | "## 4.3 Distribution" 111 | ] 112 | }, 113 | { 114 | "cell_type": "markdown", 115 | "metadata": {}, 116 | "source": [ 117 | "The distribution of a constant or a variable is defined as the multiplication of the constant or variable by each term in a _group_. The _group_ is placed in parenthesis. The constant or variable is placed outside the parenthesis. The multiplication is performed on each term in the group." 118 | ] 119 | }, 120 | { 121 | "cell_type": "markdown", 122 | "metadata": {}, 123 | "source": [ 124 | "__Definition 4.3.1__ The __distribution__ of a constant or a variable over a group of terms with addition is defined in __Equation 4.3.1__." 125 | ] 126 | }, 127 | { 128 | "cell_type": "markdown", 129 | "metadata": {}, 130 | "source": [ 131 | "$$\n", 132 | "x(a + b + c + \\ldots + n) = ax + bx + cx + \\ldots + nx \\tag{Equation 4.3.1}\n", 133 | "$$" 134 | ] 135 | }, 136 | { 137 | "cell_type": "markdown", 138 | "metadata": {}, 139 | "source": [ 140 | "__Problem 4.3.1__ Distribute the constant 3 over the group $a + b + c + d$." 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "The solution is shown in __Equation 4.3.2__." 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "$$\n", 155 | "3 \\left( a + b + c + d \\right) = 3a + 3b + 3c + 3d \\tag{Equation 4.3.2}\n", 156 | "$$" 157 | ] 158 | }, 159 | { 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "__Homework 4.3.1__ Distribute the constant 4 over the group $a + b + c + d + e + f$." 164 | ] 165 | }, 166 | { 167 | "cell_type": "markdown", 168 | "metadata": {}, 169 | "source": [ 170 | "__Problem 4.3.2__ Distribute $2$ over the expression $4x+3y-6$." 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "The solution is shown in __Equation 4.3.3__." 178 | ] 179 | }, 180 | { 181 | "cell_type": "markdown", 182 | "metadata": {}, 183 | "source": [ 184 | "$$\n", 185 | "2 \\left( 4x + 3y - 6 \\right) = 2(4x) + 2(3y) - 2(6) = 8x + 6y - 12 \\tag{Equation 4.3.3}\n", 186 | "$$" 187 | ] 188 | }, 189 | { 190 | "cell_type": "markdown", 191 | "metadata": {}, 192 | "source": [ 193 | "__Homework 4.3.2__ Distribute $3$ over the expression $5x-2y+7$." 194 | ] 195 | }, 196 | { 197 | "cell_type": "markdown", 198 | "metadata": {}, 199 | "source": [ 200 | "__Problem 4.3.3__ Distribution $-1$ over the expression $2x^2 - 3x + 4$." 201 | ] 202 | }, 203 | { 204 | "cell_type": "markdown", 205 | "metadata": {}, 206 | "source": [ 207 | "The solution is shown in __Equation 4.3.4__." 208 | ] 209 | }, 210 | { 211 | "cell_type": "markdown", 212 | "metadata": {}, 213 | "source": [ 214 | "$$\n", 215 | "-1 \\left( 2x^2 - 3x + 4 \\right) = -1(2x^2) + -1(-3x) + -1(4) = -2x^2 + 3x - 4 \\tag{Equation 4.3.4}\n", 216 | "$$" 217 | ] 218 | }, 219 | { 220 | "cell_type": "markdown", 221 | "metadata": {}, 222 | "source": [ 223 | "It wold be more common to write __Equation 4.3.4__ with only a negative $-$ and not $-1$. So we would write $- \\left( 2x^{2} - 3x +4 \\right) = -2 x^{2} - x +4$." 224 | ] 225 | }, 226 | { 227 | "cell_type": "markdown", 228 | "metadata": {}, 229 | "source": [ 230 | "__Homework 4.3.3__ Distribution $-1$ over the expression $-3x^2 - 4x - 5$." 231 | ] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "metadata": {}, 236 | "source": [ 237 | "Note that distribution is only defined for the set of parentheses that it precedes." 238 | ] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "metadata": {}, 243 | "source": [ 244 | "__Problem 4.3.4__ Simplify the expression $4x(x-2) - (5x+3)$ by distribution." 245 | ] 246 | }, 247 | { 248 | "cell_type": "markdown", 249 | "metadata": {}, 250 | "source": [ 251 | "The solution is shown in __Equation 4.3.5__." 252 | ] 253 | }, 254 | { 255 | "cell_type": "markdown", 256 | "metadata": {}, 257 | "source": [ 258 | "$$\n", 259 | "\\begin{align*}\n", 260 | "&4x(x-2) - (5x+3) = 4x^2 - 8x - 5x - 3 \\\\ \\\\\n", 261 | "&4x(x-2) - (5x+3) = 4x^2 - 13x - 3\n", 262 | "\\end{align*}\n", 263 | "\\tag{Equation 4.3.5}\n", 264 | "$$" 265 | ] 266 | }, 267 | { 268 | "cell_type": "markdown", 269 | "metadata": {}, 270 | "source": [ 271 | "In the solution above, we used the distribution $-1(5x+3)= -5x - 3$. We also grouped the terms $-8x$ and $-5x$ together such that $-8x-5x = -13x$." 272 | ] 273 | }, 274 | { 275 | "cell_type": "markdown", 276 | "metadata": {}, 277 | "source": [ 278 | "__Problem 4.3.5__ Expand the expression $a \\left( a^{4} + 2a^{2} +3\\right)$ by distribution." 279 | ] 280 | }, 281 | { 282 | "cell_type": "markdown", 283 | "metadata": {}, 284 | "source": [ 285 | "The solution is shown in __Equation 4.3.6__." 286 | ] 287 | }, 288 | { 289 | "cell_type": "markdown", 290 | "metadata": {}, 291 | "source": [ 292 | "$$\n", 293 | "\\begin{align*}\n", 294 | "&a \\left( a^{4} + 2a^{2} +3\\right) = a \\times a^{4} + 2 \\times a \\times a^{2} + 3 \\times a \\\\ \\\\\n", 295 | "&a \\left( a^{4} + 2a^{2} +3\\right) = a^{1+4} + 2a^{1+2} + 3a^{1} \\\\ \\\\\n", 296 | "&a \\left( a^{4} + 2a^{2} +3\\right) = a^{5} + 2a^{3} + 3a\n", 297 | "\\end{align*}\n", 298 | "\\tag{Equation 4.3.6}\n", 299 | "$$" 300 | ] 301 | }, 302 | { 303 | "cell_type": "markdown", 304 | "metadata": {}, 305 | "source": [ 306 | "We confirm the last result using `sympy`. We start by defining the symbols $a$ as a mathematical symbol using the `symbols` function and assign it to the variable `a`." 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": 3, 312 | "metadata": {}, 313 | "outputs": [], 314 | "source": [ 315 | "# Assign the symbol a to the variable a\n", 316 | "a = symbols('a')" 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": 4, 322 | "metadata": {}, 323 | "outputs": [ 324 | { 325 | "data": { 326 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI8AAAAaCAYAAACOyA9jAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFh0lEQVRoBe2b63EUORCAB5cDML4MTAZgMjAZwGUAZADlf/5HQQZABDwygIvgDjKADM61Gfi+TydNzWi1j1mNxzuGrhIaadSt7la/NGvuXF1dNfsMFxcX32gP9pnHIbwhyxHrzyPOSeyfMr8YQmcf1h5cBxMo4hntrJY2NF5A434tnT3Df41cL2N7Am+XtG97xmOPHXh925uIg9GNh40eQ/sB/dfShtvOga/x/dx2/YzW5Y71Gt5PkHefnUSD/5LreFTjYYMQkumf5xsNGUc6KrPKAIfsOeFadfPPhPtVb8V56MSf6M0ELYxqPFD9RCuGuHbH7R70zjfbLZ3XKuR6R+vWNxrTT+a+77Mk8g1/z+kNEAEO00NtD9ETaJzSP6qhBb5p73MNjTFxo1wvI81TemsUa5bqw4aG0TWk+Uh/8i7KlzKFhuE5mqZKUd/A8J5mrdaMGXlUsNa5M0RBjun3otaJ/Lyl1+Ns3vo0Gm+AVRcC8MMhQcv6sBuJdtbfUET21VhS8W6vEWkgX3jWqHPwfB9HvFGN5xmEl4qqfPcNY4W5B3NavoWkrYnjkjC+XgvgntHkbRdw/+SVAR9aOomHbYreCaCh4XhYj2gLx3FuMD3wauRTL5YIXd2miHOeM8M65dZ5/vTdKGkLoummUFUIQkfG2nTAWCUr4KvIOI+DQYO07QJGlx/sfTfbXwXrgR76oCgpDrh6t8aT9KaBptT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0/pu8ivrf0ZS8+ZegPTcHo17diRp2EDvwf5B1R+2v4Nt0MDpqqlm/d/qalresGm3QgAAAAASUVORK5CYII=", 327 | "text/latex": [ 328 | "$\\displaystyle a \\left(a^{4} + 2 a^{2} + 3\\right)$" 329 | ], 330 | "text/plain": [ 331 | " ⎛ 4 2 ⎞\n", 332 | "a⋅⎝a + 2⋅a + 3⎠" 333 | ] 334 | }, 335 | "execution_count": 4, 336 | "metadata": {}, 337 | "output_type": "execute_result" 338 | } 339 | ], 340 | "source": [ 341 | "# Print Problem 4.3.5 to the screen\n", 342 | "a * (a**4 + 2 * a**2 + 3)" 343 | ] 344 | }, 345 | { 346 | "cell_type": "markdown", 347 | "metadata": {}, 348 | "source": [ 349 | "We use the `expand` method to expand the expression. This performs the distribution." 350 | ] 351 | }, 352 | { 353 | "cell_type": "code", 354 | "execution_count": 5, 355 | "metadata": {}, 356 | "outputs": [ 357 | { 358 | "data": { 359 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHsAAAAVCAYAAABmOZFVAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEA0lEQVRoBd2Z7VHcMBCGTYYCgHRAOiBQQaADSAnQAQz/+MeQDiAVJNABpIIEOggdBK4D8jweyWMrR7B0N3fn25kdybK12lf7obW98vLyUuXQ2dnZJs8fwbdhntdPjN+E60E3Ad+umGCx7cDnjD/QDpreFWjvBhzCGvsS/rAshgaLdAHXmMD1hf5P+Ac8eFotRPBpGTz9Feznyfh7ro3ywVOpsSuMbapbg+/ojwa/EwHAGCfe55bRPngqSeOCPoUf4Tv4KxvkhiwVgekYvgfUJe3VMoBbyS3QUtBsxBZj97Qr6b1ZXLOuNcRJWGub1pR7wvjEBRUyzFzX8C19z++ZU8BnQSypj3gvGDfQsijb2CyyDzeVN30VeIb3ShTI0jZ5mPUEbuTtxVv0TbnH8FT0QV7tzMj7SH9iB4p69mlZz73VsNHYFX2zqA54QL+xQx95JWn8mkXcgEgboWNazyZk7cJW9yWkYZuNUACyjPIR7IZkEXPX4Ge4jU9Zklkjm5A1CT735RAZ7WMyRrRHaRaVGNvzq21YFblBofZYjhJ6r1xCFom/WTud74ZouM0coTyvYT0G2lhcw/HvcAmpW6pfXzlmEteWawo6xsustqQaN3JOWfQPra8lFf0D2zmQRt36zwaUbLJYIj4h+VHFFN5suIOzINYU33p7LcZilPuNI4s6xkaQkWBq1LM1pmeCZ3RTnNAXdCyI6M6P0OU1J6vTMPc7ZyzXffA5pzNvfgi7K6O/WaY+uuj/84bwFr4mjQdBvmpYycoaWO+xQCiJEKbOntBVQ2vUjkMy7kYNEp+YYItO6xMd8RfcoT746sjmQY1pQaOR2+eV/UfGZp7COkjyLsRhDdHORoPGB5Ym29A3jfuq21Tj9Hvhi2nc1GBBk6YGoyGrvOf5sYRss4TyUqqree53qurw0APjr6XqVE4V1tA50zlLgU/AYNORDT7fitZDvxe+aOzPTI4lvTIrhOgtpsP4d8vhYkLeOGO6jp66SdtEYskizPc1ZYO2eeduyRkkPrCMrT3AZRo3cGIw9sK3ikCNKqdGVUDF/Y4TOLZohI46jH+qmoimr6NKT/BQ8VljVGCJEexlh7jX234xshXQPqu9NkLqqhSBbqYpNX3G5+ZK6KT379B2CjLG1Ll9LKW6DwHfCAzjfjRtMy61A/FNfEb2CHZSjISKazfKTYzC/PQ4lbMbmVMjdFJnCzI3JH3v3GWsPhpoB4kPXKkDV2DRNkbzEX2dwbFe+GJkm/78e3VM64eSb7Ce72uXY+lGMrQQ5NGjwcd9bq2zUtBykPjY+ytYp23vv3jT7/698GX/CAmbN7UGIHrqxAXa1BSasqBFwvduythKxJmK6nRUMnkAcxYG31+1PfA7Rj/XLAAAAABJRU5ErkJggg==", 360 | "text/latex": [ 361 | "$\\displaystyle a^{5} + 2 a^{3} + 3 a$" 362 | ], 363 | "text/plain": [ 364 | " 5 3 \n", 365 | "a + 2⋅a + 3⋅a" 366 | ] 367 | }, 368 | "execution_count": 5, 369 | "metadata": {}, 370 | "output_type": "execute_result" 371 | } 372 | ], 373 | "source": [ 374 | "# Perform the calculation in Problem 4.3.5\n", 375 | "(a * (a**4 + 2 * a**2 + 3)).expand()" 376 | ] 377 | }, 378 | { 379 | "cell_type": "markdown", 380 | "metadata": {}, 381 | "source": [ 382 | "__Homework 4.3.4__ Simplify the expression $3x(x^{2}-2) - (4x+5)$ by distribution." 383 | ] 384 | }, 385 | { 386 | "cell_type": "markdown", 387 | "metadata": {}, 388 | "source": [ 389 | "__Problem 4.3.6__ Expand the expression in __Equation 4.3.7__ by distribution." 390 | ] 391 | }, 392 | { 393 | "cell_type": "markdown", 394 | "metadata": {}, 395 | "source": [ 396 | "$$\n", 397 | "a^{4} \\left( a^{3} + a^{\\frac{1}{4}} \\right)\n", 398 | "\\tag{Equation 4.3.7}\n", 399 | "$$" 400 | ] 401 | }, 402 | { 403 | "cell_type": "markdown", 404 | "metadata": {}, 405 | "source": [ 406 | "The result is shown in __Equation 4.3.8__ and confirmed using `sympy`." 407 | ] 408 | }, 409 | { 410 | "cell_type": "markdown", 411 | "metadata": {}, 412 | "source": [ 413 | "$$\n", 414 | "\\begin{align*}\n", 415 | "&a^{4} \\left( a^{3} + a^{\\frac{1}{4}} \\right) = a^{4} \\times a^{3} + a^{4} \\times a^{\\frac{1}{4}} \\\\ \\\\\n", 416 | "&a^{4} \\left( a^{3} + a^{\\frac{1}{4}} \\right) = a^{4+3} + a^{4+\\frac{1}{4}} \\\\ \\\\\n", 417 | "&a^{4} \\left( a^{3} + a^{\\frac{1}{4}} \\right) = a^{7} + a^{\\frac{17}{4}}\n", 418 | "\\end{align*}\n", 419 | "\\tag{Equation 4.3.8}\n", 420 | "$$" 421 | ] 422 | }, 423 | { 424 | "cell_type": "code", 425 | "execution_count": 6, 426 | "metadata": {}, 427 | "outputs": [ 428 | { 429 | "data": { 430 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEsAAAAXCAYAAABDArJmAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACpUlEQVRYCdWY0VEbMRCGbQ8FMEkHpoNACaEDoITQQZi8+RU6gFSQIR1ACUAJdJDBHTjfpznd6DRng3VnfLcza0l70mr3P+1qz9PVajUppcViMWftLXxOfxn10L+v5E+pPD4fazsrNRwQvrFWFrCclD/Ab8xbVXyWTxriGFvb/AmmHpQajNIX1r7QXrfouEV+o5w2AEr7t2XeEEVX2Boj5jU1sBisVEneZ7MIlJt+j+N83kDHwWbtzuy72wlYySb3AHWcjMfQfcXmaWooYyPlcpYK++yj3PA77FPnJ+lqpBX8cHzl3sVgCQb8Ex1f4F/08wSu3Lw2KsKPOk9VPj3Qhpt+2qV0GBUKWxoLQEaFaeQ0Li3KWSgoLs5Y28gH0ZABthfY1IiMUrD24jBAe0PNae8+AdxL9rDgrqk4Z9UaWjo4Y5zvIrmrcxd6W7wIBXdD3jtYgPSDHeaNXcY5MNE/paY3whBHddKr0on/YKvuM+ShyKS/kZjnjfgIh6t24+Q9PNzGP+Ye5SbWJ4uH5oNn2HJfFiBj9pr+u0efOdZVS9r66mU8GMKuTv7pSACrAsN/CgQpdda+Fe3SyeuoWn9C66kaHFX2FfsXHYphaOgdojS/ZXwbH/kAtgB1vUWqZDhbqPqZkIIfHr734zrmuHdO7jPhuTdVTn7Un+fCatzVv6AmgmVN0TgVbGzo6bR/tWwk5grITbXGBN+J0NMGxgS5OdHS4UM5NDGik39RzwEbC4qcg+IGGtgAUdk6Yq7hqiPbOrNOZWd5n/7VCR6r8nCxzA8VLBt6I3rKxkyd/ZtVp8HTU4MhOIy93WKdcYos32wUwPXpX8xZJsbfKDZBf4X/wJ4sywZljbKf8dioF/9G9a8DL640wffyctOc1YvCHSvxApH3Qv8BuZoQxjuQPr4AAAAASUVORK5CYII=", 431 | "text/latex": [ 432 | "$\\displaystyle a^{\\frac{17}{4}} + a^{7}$" 433 | ], 434 | "text/plain": [ 435 | " 17/4 7\n", 436 | "a + a " 437 | ] 438 | }, 439 | "execution_count": 6, 440 | "metadata": {}, 441 | "output_type": "execute_result" 442 | } 443 | ], 444 | "source": [ 445 | "# Use the expand method to perform the calculation in Problem 4.3.7\n", 446 | "(a**4 * (a**3 + a**(Rational(1, 4)))).expand()" 447 | ] 448 | }, 449 | { 450 | "cell_type": "markdown", 451 | "metadata": {}, 452 | "source": [ 453 | "__Homework 4.3.5__ Expand the expression in __Equation 4.3.9__ by distribution." 454 | ] 455 | }, 456 | { 457 | "cell_type": "markdown", 458 | "metadata": {}, 459 | "source": [ 460 | "$$\n", 461 | "x^{\\frac{1}{3}} \\left( x^{3} + 2 \\right)\n", 462 | "\\tag{4.3.9}\n", 463 | "$$" 464 | ] 465 | }, 466 | { 467 | "cell_type": "markdown", 468 | "metadata": {}, 469 | "source": [ 470 | "__Problem 4.3.7__ Expand the expression in __Equation 4.3.10__ by distribution." 471 | ] 472 | }, 473 | { 474 | "cell_type": "markdown", 475 | "metadata": {}, 476 | "source": [ 477 | "$$\n", 478 | "5 a^{-3}b^{-2} \\left( 2ab^{3} - 3a^{2}b^{2} \\right)\n", 479 | "\\tag{Equation 4.3.10}\n", 480 | "$$" 481 | ] 482 | }, 483 | { 484 | "cell_type": "markdown", 485 | "metadata": {}, 486 | "source": [ 487 | "The solution follows in __Equation 4.3.11__." 488 | ] 489 | }, 490 | { 491 | "cell_type": "markdown", 492 | "metadata": {}, 493 | "source": [ 494 | "$$\n", 495 | "\\begin{align*}\n", 496 | "&5 a^{-3}b^{-2} \\left( 2ab^{3} - 3a^{2}b^{2} \\right) \\\\ \\\\\n", 497 | "= &2 \\cdot 5 \\cdot a \\cdot a^{-3} \\cdot b^{3} \\cdot b^{-2} - 3 \\cdot 5 \\cdot a^{2} \\cdot a^{-3} \\cdot b^{2} \\cdot b^{-2} \\\\ \\\\ \n", 498 | "= &10 a^{1-3} b^{3-2} - 15 a^{2-3} b^{2-2} \\\\ \\\\\n", 499 | "= &10 a^{-2} b - 15 a^{-1} \\\\ \\\\\n", 500 | "= &\\frac{10 b}{a^{2}} - \\frac{15}{a}\n", 501 | "\\end{align*}\n", 502 | "\\tag{Equation 4.3.11}\n", 503 | "$$" 504 | ] 505 | }, 506 | { 507 | "cell_type": "markdown", 508 | "metadata": {}, 509 | "source": [ 510 | "We confirm the result with code after assigning the mathematical symbol $b$ to the variable `b` using the `symbols` function." 511 | ] 512 | }, 513 | { 514 | "cell_type": "code", 515 | "execution_count": 7, 516 | "metadata": {}, 517 | "outputs": [], 518 | "source": [ 519 | "# Create the mathematical symbol b and assign it to the variable b\n", 520 | "b = symbols('b')" 521 | ] 522 | }, 523 | { 524 | "cell_type": "code", 525 | "execution_count": 8, 526 | "metadata": {}, 527 | "outputs": [ 528 | { 529 | "data": { 530 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGMAAAAsCAYAAABxNQYsAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE7klEQVR4Ae2b7VHcMBCGTYYCjqSDSweQVBDoANIB0EGY/IJ/DOkAUgEhHQAVECiBDsLQAXkfxeuRHdv4HNuS77wzOknrtbQfWmkl65KXl5ckRDo+Pt4s9ivcTGlexK9KfT3pCU5OTjbV9JXSlsrPJd3cCj8T/iF9RhnY+pvF89tAlkQ0ZynHv5W/VzoT7tGkUBn50McHpSfVoclBp8ZIO/yuHp6U6HSe6y1fgQbAaDD9U+lUbZQZTo+GhUVkEe29uIN3ZEjSd++V7yg5gyhHLurQ/oKuCF0bgw736ESdflGGoqvgQTSOtoogJF68NZJFdAfic6bcGQKeeTetn6u6A84DdHLq1bPim6w0FdpqgAFlU63fxp0q2zLKzJAqb6flG8P5+WQMXxvtyijYply/BVsvzAA8w0se8Ryf0MqdTlPWaNNcTDkXF/07JdYX5t2yUda0yUHpxGs26ms6fus9wzBMz0zhwEelS9XdFBfSMxDkhxj5pnSkMolFzx9JQkUNpujSkZ5y7gwmuchZLxh0F8itfF/pSmVwSTBjiAEii0wIlXFr5lIWvWUCvB6wQfbJ5E5zdLALQTBj0HkJYJC5mHQjpeR5bKiytcJ4NK9h3wGwXjBFZQPQYRWJKXcGC2IMMXStRLxdBTAYPXiKLePXcP5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displaystyle - \\frac{15}{a} + \\frac{10 b}{a^{2}}$" 533 | ], 534 | "text/plain": [ 535 | " 15 10⋅b\n", 536 | "- ── + ────\n", 537 | " a 2 \n", 538 | " a " 539 | ] 540 | }, 541 | "execution_count": 8, 542 | "metadata": {}, 543 | "output_type": "execute_result" 544 | } 545 | ], 546 | "source": [ 547 | "# Solution to Problem 4.3.7\n", 548 | "(5 * a**(-3) * b**(-2) * (2 * a * b**3 - 3 * a**2 * b**2)).expand()" 549 | ] 550 | }, 551 | { 552 | "cell_type": "markdown", 553 | "metadata": {}, 554 | "source": [ 555 | "__Homework 4.3.6__ Expand the expression in __Equation 4.3.12__ by distribution." 556 | ] 557 | }, 558 | { 559 | "cell_type": "markdown", 560 | "metadata": {}, 561 | "source": [ 562 | "$$\n", 563 | "x^{-3}y^{4} \\left( x y + x^{-2} y^{5} \\right)\n", 564 | "\\tag{Equation 4.3.12}\n", 565 | "$$" 566 | ] 567 | }, 568 | { 569 | "cell_type": "markdown", 570 | "metadata": {}, 571 | "source": [ 572 | "Radicals can also be involved in distribution. To do these calculations we remember the property of radicals in __Equation 4.3.13__, where $a,b \\ge 0$." 573 | ] 574 | }, 575 | { 576 | "cell_type": "markdown", 577 | "metadata": {}, 578 | "source": [ 579 | "$$\n", 580 | "\\sqrt[n]{ab} = \\left( ab \\right)^{\\frac{1}{n}}\n", 581 | "\\tag{Equation 4.3.13}\n", 582 | "$$" 583 | ] 584 | }, 585 | { 586 | "cell_type": "markdown", 587 | "metadata": {}, 588 | "source": [ 589 | "We can examine a specific example to confirm that all the terms in __Equation 4.3.11__ are indeed equal. If we use $a=2$, $b=3$ and $n=2$ we have $\\sqrt[2]{2 \\times 3}$. The code below calculates the values of each term in __Equation 4.3.11__ and confirms that they are all equal." 590 | ] 591 | }, 592 | { 593 | "cell_type": "code", 594 | "execution_count": 9, 595 | "metadata": {}, 596 | "outputs": [ 597 | { 598 | "data": { 599 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAAVCAYAAAC33pUlAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB2ElEQVRIDa2V7VECMRCGD8YC1BKwA6AU0AqADmT8d/8Y7UCtQKEEShBKoANHOjjfJ2bPXMjp3Q07syTZr3d3sxd6RVFkXSnP86F8d039L5oa1tg9Sj4S6L5GXxH3K6cWB19V1hSI0J3B5PsgprLG1AlM1QyEMNC6bYwkw653tpQvfEJKIK72zVrdGkyOl0IYa12ESDpT7Vq81N5VrJUzfCPudGdkvsI5IoJSRdhaEjuYXa/Nd6ZAOO+0ukwtiM4T7QG70v5o8nhtOyB1E0hLj38BAVzemc8Oh7ANcXIT6StVeYOx1oN0vCh34k8xduswngOT4F4Ksqa/I/EJeZvnE8WPgPZCDE45pdp/iWfiDcq+NmTz4nnoz+hiWkj3FAslMyB8iRPSuw6vZgPYXsyl2oRRYYWkn0tQV5XZllNnAq080iRDm39H3wOSGffCNxMSrYmzdnrvx56E68jFi6fRvv6w74z1JgiaCshQWTtTeld1BUwBEeI4196caau1OBUIGS2Ou4GcYSsnvAKGVmTVAUhVH/9UlUnPtG21mi8ykr0Vz8SOki+IDLlYMqXSqc6py3cBwh/ZAWYdudZ+JVn5x1oHRkU8P9zVVOtZKNXGTAC0hYzKQTkH2jfJSLCHqLYlZwAAAABJRU5ErkJggg==", 600 | "text/latex": [ 601 | "$\\displaystyle \\sqrt{6}$" 602 | ], 603 | "text/plain": [ 604 | "√6" 605 | ] 606 | }, 607 | "execution_count": 9, 608 | "metadata": {}, 609 | "output_type": "execute_result" 610 | } 611 | ], 612 | "source": [ 613 | "sqrt(2 * 3)" 614 | ] 615 | }, 616 | { 617 | "cell_type": "code", 618 | "execution_count": 10, 619 | "metadata": {}, 620 | "outputs": [ 621 | { 622 | "data": { 623 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAAVCAYAAAC33pUlAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB2ElEQVRIDa2V7VECMRCGD8YC1BKwA6AU0AqADmT8d/8Y7UCtQKEEShBKoANHOjjfJ2bPXMjp3Q07syTZr3d3sxd6RVFkXSnP86F8d039L5oa1tg9Sj4S6L5GXxH3K6cWB19V1hSI0J3B5PsgprLG1AlM1QyEMNC6bYwkw653tpQvfEJKIK72zVrdGkyOl0IYa12ESDpT7Vq81N5VrJUzfCPudGdkvsI5IoJSRdhaEjuYXa/Nd6ZAOO+0ukwtiM4T7QG70v5o8nhtOyB1E0hLj38BAVzemc8Oh7ANcXIT6StVeYOx1oN0vCh34k8xduswngOT4F4Ksqa/I/EJeZvnE8WPgPZCDE45pdp/iWfiDcq+NmTz4nnoz+hiWkj3FAslMyB8iRPSuw6vZgPYXsyl2oRRYYWkn0tQV5XZllNnAq080iRDm39H3wOSGffCNxMSrYmzdnrvx56E68jFi6fRvv6w74z1JgiaCshQWTtTeld1BUwBEeI4196caau1OBUIGS2Ou4GcYSsnvAKGVmTVAUhVH/9UlUnPtG21mi8ykr0Vz8SOki+IDLlYMqXSqc6py3cBwh/ZAWYdudZ+JVn5x1oHRkU8P9zVVOtZKNXGTAC0hYzKQTkH2jfJSLCHqLYlZwAAAABJRU5ErkJggg==", 624 | "text/latex": [ 625 | "$\\displaystyle \\sqrt{6}$" 626 | ], 627 | "text/plain": [ 628 | "√6" 629 | ] 630 | }, 631 | "execution_count": 10, 632 | "metadata": {}, 633 | "output_type": "execute_result" 634 | } 635 | ], 636 | "source": [ 637 | "sqrt(2) * sqrt(3)" 638 | ] 639 | }, 640 | { 641 | "cell_type": "code", 642 | "execution_count": 11, 643 | "metadata": {}, 644 | "outputs": [ 645 | { 646 | "data": { 647 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAAVCAYAAAC33pUlAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB2ElEQVRIDa2V7VECMRCGD8YC1BKwA6AU0AqADmT8d/8Y7UCtQKEEShBKoANHOjjfJ2bPXMjp3Q07syTZr3d3sxd6RVFkXSnP86F8d039L5oa1tg9Sj4S6L5GXxH3K6cWB19V1hSI0J3B5PsgprLG1AlM1QyEMNC6bYwkw653tpQvfEJKIK72zVrdGkyOl0IYa12ESDpT7Vq81N5VrJUzfCPudGdkvsI5IoJSRdhaEjuYXa/Nd6ZAOO+0ukwtiM4T7QG70v5o8nhtOyB1E0hLj38BAVzemc8Oh7ANcXIT6StVeYOx1oN0vCh34k8xduswngOT4F4Ksqa/I/EJeZvnE8WPgPZCDE45pdp/iWfiDcq+NmTz4nnoz+hiWkj3FAslMyB8iRPSuw6vZgPYXsyl2oRRYYWkn0tQV5XZllNnAq080iRDm39H3wOSGffCNxMSrYmzdnrvx56E68jFi6fRvv6w74z1JgiaCshQWTtTeld1BUwBEeI4196caau1OBUIGS2Ou4GcYSsnvAKGVmTVAUhVH/9UlUnPtG21mi8ykr0Vz8SOki+IDLlYMqXSqc6py3cBwh/ZAWYdudZ+JVn5x1oHRkU8P9zVVOtZKNXGTAC0hYzKQTkH2jfJSLCHqLYlZwAAAABJRU5ErkJggg==", 648 | "text/latex": [ 649 | "$\\displaystyle \\sqrt{6}$" 650 | ], 651 | "text/plain": [ 652 | "√6" 653 | ] 654 | }, 655 | "execution_count": 11, 656 | "metadata": {}, 657 | "output_type": "execute_result" 658 | } 659 | ], 660 | "source": [ 661 | "(2**(Rational(1, 2)) * 3**(Rational(1, 2)))" 662 | ] 663 | }, 664 | { 665 | "cell_type": "code", 666 | "execution_count": 12, 667 | "metadata": {}, 668 | "outputs": [ 669 | { 670 | "data": { 671 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABsAAAAVCAYAAAC33pUlAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB2ElEQVRIDa2V7VECMRCGD8YC1BKwA6AU0AqADmT8d/8Y7UCtQKEEShBKoANHOjjfJ2bPXMjp3Q07syTZr3d3sxd6RVFkXSnP86F8d039L5oa1tg9Sj4S6L5GXxH3K6cWB19V1hSI0J3B5PsgprLG1AlM1QyEMNC6bYwkw653tpQvfEJKIK72zVrdGkyOl0IYa12ESDpT7Vq81N5VrJUzfCPudGdkvsI5IoJSRdhaEjuYXa/Nd6ZAOO+0ukwtiM4T7QG70v5o8nhtOyB1E0hLj38BAVzemc8Oh7ANcXIT6StVeYOx1oN0vCh34k8xduswngOT4F4Ksqa/I/EJeZvnE8WPgPZCDE45pdp/iWfiDcq+NmTz4nnoz+hiWkj3FAslMyB8iRPSuw6vZgPYXsyl2oRRYYWkn0tQV5XZllNnAq080iRDm39H3wOSGffCNxMSrYmzdnrvx56E68jFi6fRvv6w74z1JgiaCshQWTtTeld1BUwBEeI4196caau1OBUIGS2Ou4GcYSsnvAKGVmTVAUhVH/9UlUnPtG21mi8ykr0Vz8SOki+IDLlYMqXSqc6py3cBwh/ZAWYdudZ+JVn5x1oHRkU8P9zVVOtZKNXGTAC0hYzKQTkH2jfJSLCHqLYlZwAAAABJRU5ErkJggg==", 672 | "text/latex": [ 673 | "$\\displaystyle \\sqrt{6}$" 674 | ], 675 | "text/plain": [ 676 | "√6" 677 | ] 678 | }, 679 | "execution_count": 12, 680 | "metadata": {}, 681 | "output_type": "execute_result" 682 | } 683 | ], 684 | "source": [ 685 | "(2 * 3)**Rational(1, 2)" 686 | ] 687 | }, 688 | { 689 | "cell_type": "markdown", 690 | "metadata": {}, 691 | "source": [ 692 | "In each case the result is $\\sqrt{6}$." 693 | ] 694 | }, 695 | { 696 | "cell_type": "markdown", 697 | "metadata": {}, 698 | "source": [ 699 | "__Problem 4.3.8__ Expand the expression in __Equation 4.3.14__ where $x,y \\ge 0$, by distribution." 700 | ] 701 | }, 702 | { 703 | "cell_type": "markdown", 704 | "metadata": {}, 705 | "source": [ 706 | "$$\n", 707 | "\\sqrt{xy} \\left( \\sqrt{xy} + \\sqrt{y} \\right)\n", 708 | "\\tag{Equation 4.3.14}\n", 709 | "$$" 710 | ] 711 | }, 712 | { 713 | "cell_type": "markdown", 714 | "metadata": {}, 715 | "source": [ 716 | "The result is shown in __Equation 4.3.15__." 717 | ] 718 | }, 719 | { 720 | "cell_type": "markdown", 721 | "metadata": {}, 722 | "source": [ 723 | "$$\n", 724 | "\\begin{align*}\n", 725 | "&\\sqrt{xy} \\left( \\sqrt{xy} + \\sqrt{y} \\right) \\\\ \\\\\n", 726 | "&= \\sqrt{xy} \\times \\sqrt{xy} + \\sqrt{xy} \\times \\sqrt{y} \\\\ \\\\\n", 727 | "&= \\sqrt{x^{2}y^{2}} + \\sqrt{xy^{2}} \\\\ \\\\\n", 728 | "&= \\sqrt{x^{2}} \\sqrt{y^{2}} + \\sqrt{x} \\sqrt{y^{2}} \\\\ \\\\\n", 729 | "&= xy + \\sqrt{x} y\n", 730 | "\\end{align*}\n", 731 | "\\tag{Equation 4.3.15}\n", 732 | "$$" 733 | ] 734 | }, 735 | { 736 | "cell_type": "markdown", 737 | "metadata": {}, 738 | "source": [ 739 | "We can only write $\\sqrt{x^{2}y^{2}} = \\sqrt{x^{2}} \\sqrt{y^{2}}$ because $x^{2}$ and $y^{2}$ are both positive numbers. We constrained $x$ and $y$ to be positive in this problem. Even if both were negative, the result would still be the same (for the first term)." 740 | ] 741 | }, 742 | { 743 | "cell_type": "markdown", 744 | "metadata": {}, 745 | "source": [ 746 | "The result is confirmed in the code cell below. We start by creating the mathematical variables $x$ and $y$ assigned to the variables `x` and `y` respectively. The variables are constrained to be positive. We then use the `expand` method to expand the expression." 747 | ] 748 | }, 749 | { 750 | "cell_type": "code", 751 | "execution_count": 13, 752 | "metadata": {}, 753 | "outputs": [], 754 | "source": [ 755 | "# Creating the mathematical variable x and y\n", 756 | "x, y = symbols('x y', positive=True)" 757 | ] 758 | }, 759 | { 760 | "cell_type": "code", 761 | "execution_count": 14, 762 | "metadata": {}, 763 | "outputs": [ 764 | { 765 | "data": { 766 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAFcAAAAVCAYAAAAzWHILAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADJ0lEQVRYCe2Z4VHbMBTHHS4DcO0G6QalnaBhA2gnKGwAx7d869ENCiPABnQDCiOwQXNskP5+PskojhNix07dX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| "text/plain": [ 771 | "√x⋅y + x⋅y" 772 | ] 773 | }, 774 | "execution_count": 14, 775 | "metadata": {}, 776 | "output_type": "execute_result" 777 | } 778 | ], 779 | "source": [ 780 | "# Verify the result\n", 781 | "(sqrt(x * y) * (sqrt(x * y) + sqrt(y))).expand()" 782 | ] 783 | }, 784 | { 785 | "cell_type": "markdown", 786 | "metadata": {}, 787 | "source": [ 788 | "__Homework 4.3.7__ Expand the expression in $\\sqrt{xy} \\left( \\sqrt{x} + \\sqrt{y} \\right)$ where $x$ and $y$ are positive, by distribution." 789 | ] 790 | }, 791 | { 792 | "cell_type": "markdown", 793 | "metadata": {}, 794 | "source": [ 795 | "__Problem 4.3.9__ Simplify the expression in __Equation 4.3.16__ where $x,y>0$, by distribution." 796 | ] 797 | }, 798 | { 799 | "cell_type": "markdown", 800 | "metadata": {}, 801 | "source": [ 802 | "$$\n", 803 | "\\sqrt{xy^{3}} \\left( \\sqrt{x^{5}y} + \\sqrt{xy^{7}} \\right)\n", 804 | "\\tag{Equation 4.3.16}\n", 805 | "$$" 806 | ] 807 | }, 808 | { 809 | "cell_type": "markdown", 810 | "metadata": {}, 811 | "source": [ 812 | "The solution follows in __Equation 4.3.17__ where we make use of radicals." 813 | ] 814 | }, 815 | { 816 | "cell_type": "markdown", 817 | "metadata": {}, 818 | "source": [ 819 | "$$\n", 820 | "\\begin{align*}\n", 821 | "&\\sqrt{xy^{3}} \\left( \\sqrt{x^{5}y} + \\sqrt{xy^{7}} \\right) \\\\ \\\\\n", 822 | "= &x^{\\frac{1}{2}} y^{\\frac{3}{2}} \\left( x^{\\frac{5}{2}} y^{\\frac{1}{2}} + x^{\\frac{1}{2}} y^{\\frac{7}{2}} \\right) \\\\ \\\\\n", 823 | "= &x^{\\frac{1}{2} + \\frac{5}{2}} y^{\\frac{3}{2} + \\frac{1}{2}} + x^{\\frac{1}{2} + \\frac{1}{2}} y^{\\frac{3}{2} + \\frac{7}{2}} \\\\ \\\\\n", 824 | "= &x^{3} y^{2} + x y^{5}\n", 825 | "\\end{align*}\n", 826 | "\\tag{Equation 4.3.17}\n", 827 | "$$" 828 | ] 829 | }, 830 | { 831 | "cell_type": "markdown", 832 | "metadata": {}, 833 | "source": [ 834 | "We solve the problem using the `expand` method in the code cell below." 835 | ] 836 | }, 837 | { 838 | "cell_type": "code", 839 | "execution_count": 15, 840 | "metadata": {}, 841 | "outputs": [ 842 | { 843 | "data": { 844 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGIAAAAXCAYAAADwSpp8AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAD30lEQVRoBd2Z7VEbMRCG7QwFkKQD6ACSCuJ0kIQKgA7C8I9/DHQAVEBwB5AK+CjBqSCMOyDPc5ZuhGOwpTt7jHdmLd2etNa+q92V7O7T01Mnl46OjjaY04MfYfuf4WPkD7TZxLx1Jh2GieqTdpEPR93V+Ay47WPNdbBIWx+R99cKTTxh3gAF586n/UnzG37vcwGdoMMFVkT/jM49vDmSrMynwO/B4jWA+9haYfiOhxI6ZtJlMvEjfaOjlPZYkBEWSUdvINuKghVqv2BXF96ED6JdRRGBgvEU9A2FgldKRsNd6eS3Ng/83HSm4xv6VfotckQ0HCWG2A58Rr8Ksfgup50wV8eY+sYdnqN2WcdaC40EM8gFNl7C/W5JsU4tRImevYKv6Z+m70r66DAdqW+b/koV63E8gq33tN3SGlHrDGDpYQtuo5zOfIuZKW4lnYB9pvCULNgd5L3s1MQkI+APbNGJqSPu3E/Io4zu7IQunXBA+9VZ4dm2WuzsmkaGMd5iX5wuc74vY+wVa3KTRYw+hLmD7IhAiaCb31KALD7Kf8HZhE6d4JHVWrMl0495NFsfE9ws8rKRGyPFzQjxCDvIjohg2XfaQxT8Dc9e6JqkE+8MAmdbE/rru0UtfNsdN1fEzSN/BxvFslMXawQC4WVDEthd2J26A0u3jOmPutM/E31eyixIdZoI7zwxVIuYri1vBHrdaaamosNDWN9MWCRjG9mZpiaL7WlY/C2GXMA9nvWiTsq9J+h5gfA6Pz73B7LxwoVoaSgHi1bsrFITgOn9FKwhzwJlVEgWlfR9JXzpA33meJ0pWXytKSkpu0kFy9LPwaJNO2ONuENpWkS2AeYBmQ7p0OamkPQy5u73J5GULO7jsvT9TH3WZYFX1zhVpxHeT6ox2vWaPTlYtGZnjIh4nIoGTQIvvpvaYmh0oCCZ1tL6YLQoaxwRLwDdQV5cI5g7MxaMbc3OtEaATX0GF6i6MPOF63I1IO/DnVdHVpiqc4YTDM7TvIDRrDFupGlYNLZzLQDsTwoWKHep4SxQaaqyIFm0c8lTV6rH+ctcH9xsJVg0ttOI0Ouyf1C4kGeFFZnvYuGlm0XPnBB0qS/+MZKlbAGDS7FobOcaxhkF5nAX0QGsfdgf8OKfMzqoDk3HZJBR5H3BE5eXv/hHT+P6kLGGnKGlWDS2s77Q5ay2dGxwSI/WU9ncCP3FxbqNRZXY+V+xbmMh6nAxcP2TBX3TnveVxsdW9U+hIe/luVNbdpqa5kXuStNbJG/q5yy8NM1FPVNbvmORqa8VO+eWmgDDBXqxMhKsDf4EvEiA+Mr5U1t2/gOyfNNnSJKoZgAAAABJRU5ErkJggg==", 845 | "text/latex": [ 846 | "$\\displaystyle x^{3} y^{2} + x y^{5}$" 847 | ], 848 | "text/plain": [ 849 | " 3 2 5\n", 850 | "x ⋅y + x⋅y " 851 | ] 852 | }, 853 | "execution_count": 15, 854 | "metadata": {}, 855 | "output_type": "execute_result" 856 | } 857 | ], 858 | "source": [ 859 | "# Verify the result of Problem 4.3.8\n", 860 | "(sqrt(x * y**3) * (sqrt(x**5 * y) + sqrt(x * y**7))).expand()" 861 | ] 862 | }, 863 | { 864 | "cell_type": "markdown", 865 | "metadata": {}, 866 | "source": [ 867 | "Note that if it is not stipulated that $x$ and $y$ are positive, then the combination of the bases are not possible. For example, $\\sqrt{-1} \\times \\sqrt{-1}$ is not $\\sqrt{-1 \\times -1} = \\sqrt{1} = \\pm 1$. This is because $\\sqrt{-1} = i$, the imaginary unit and $i^{2}=-1$." 868 | ] 869 | }, 870 | { 871 | "cell_type": "markdown", 872 | "metadata": {}, 873 | "source": [ 874 | "Below, we recreate the mathematical variables $x$ and $y$, but allow them to be any real number." 875 | ] 876 | }, 877 | { 878 | "cell_type": "code", 879 | "execution_count": 25, 880 | "metadata": {}, 881 | "outputs": [], 882 | "source": [ 883 | "# Recreate variables x and y\n", 884 | "x, y = symbols('x y', real=True)" 885 | ] 886 | }, 887 | { 888 | "cell_type": "markdown", 889 | "metadata": {}, 890 | "source": [ 891 | "Now we have that $\\sqrt{x} \\sqrt{y} \\ne \\sqrt{xy}$." 892 | ] 893 | }, 894 | { 895 | "cell_type": "code", 896 | "execution_count": 17, 897 | "metadata": {}, 898 | "outputs": [ 899 | { 900 | "data": { 901 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAADgAAAAXCAYAAABefIz9AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADHklEQVRYCb2X21EcMRBFZykHQBECzgBMBpABa0cAZGAXf/y5cAZABBRkgB0BhgxMCBQZrM+R1fLMvtjRwHZV03p0q19XmmU0mUyaWjo7O9vB9qGPPTajPvpDdT8MPOAc+12Cfhx4zruZVyeYu9esO7nsd2XUVCdIyU9hO7hu6oWajZroqOI2dtvInzX2tTa5ew1y5StRlSABfstcG2utXW/U9E6Q6m0S3SfkurtXhZreCZKcd+B7bQsG2FWhZtTnO5i794D8OB1o3jvO63vII9iqf8lr9+jc5nEvkc/+hdwNw5Y/YzGmy6m9K9bGfTu47A6cc+APGUf38BW8z9zKC+shL+481JxmX3dzzv7M2iHclM8Eyi68IJfdrUP253XPzrUTeGHueXZR2oLb+2lxlT/4szgW6iT0GfsLyiJKB/BzGv3/41rKIyWIwVcW7M4TXGDAuFDWuSgL3cFv9rUN8oxH1ky0QY5jo0LOQ80TZ8anwm5Nvwn7sbaBotUQv/JOnjOcoRP2hN8MtZzFnk6vY7JIYiciDGYZqVPul4rMo3Da2uGyz575uJY6aIJR6aiCFesQOkJwUfemdcNpeVCw35TbisxFjfd0IXSzzjK/IiPij+P171VLHS6PDAtWxUpYse3QztKHolSpvYeuwd/B0Qnvig7akPVB8PxEjAejJh9lnG0/Lpf756Qk6ASKappQIoLxsbhtB5i3QpiY/IyOXepceNbciweBYYJYVH0oajrJZV/682VN1EkQBQ3E7nEOViUhG4E4nyb17a4Ha2cHj5AXsNC2wwWuzAuxXoWacsC/n4wN5/iJEvLxmKX7p97Mhx7FqIBdNOED1gz6XYizhdkf+DL8IEXNHrIgaRXn6ItAPynlS9DpoIewafZeUDsnB2wZvj3hrwY1xmnXyv+FjL0eIqaDtpkEcwoqaeD3poPzvP/WIoooxO2e31Xhu4zUu24p+CKLgs51mIFoGKBodcbIdSTYZH/CVX+v+kXfBLdgG+GvqxvWyt1jnmhhgqGwLpkDvsGfL3Y8FoPdL4Lo4IP7HkBSQsu73+thec3PX4HeUQSVfbGjAAAAAElFTkSuQmCC", 902 | "text/latex": [ 903 | "$\\displaystyle \\sqrt{x} \\sqrt{y}$" 904 | ], 905 | "text/plain": [ 906 | "√x⋅√y" 907 | ] 908 | }, 909 | "execution_count": 17, 910 | "metadata": {}, 911 | "output_type": "execute_result" 912 | } 913 | ], 914 | "source": [ 915 | "sqrt(x) * sqrt(y)" 916 | ] 917 | }, 918 | { 919 | "cell_type": "markdown", 920 | "metadata": {}, 921 | "source": [ 922 | "Above, the bases $x$ and $y$ are not the same. Below, however, we have that the bases, $xy$, are the same. We can confirm that $\\sqrt{xy} \\sqrt{xy} = xy$." 923 | ] 924 | }, 925 | { 926 | "cell_type": "code", 927 | "execution_count": 18, 928 | "metadata": {}, 929 | "outputs": [ 930 | { 931 | "data": { 932 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABcAAAANCAYAAABCZ/VdAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABgklEQVQ4Ea2U0U0DMQyGr6gDVIxQNgCxQdmAwgTQERBP1zdUNqCdAJUNygblOkI3oOoG5fsi55oTDyCEJZ/tP47t2Mn1DodDJU2n0wHiPhlVdYm8g4fwbWBrfN7UC98zzAZ7Hj55bQE2PskgcgbwLKOv4QU8wn5AmngGZ3oMvxVAibt+A1+r9P3gaMWl0x5bB6uXTuG0ju85usmlK3iXtONH7F0zBUd+sGkrEHSB3ICZpEKOA1dssTdhW+VT6FmMMpbaUjhnBze9ZqOU+OaEBrFdZb89lViqvOw5WKoyb0rDC2xAUDeV5Gna08WCe/e52H5sWgI6UDNOwqFskwN0sCUNMUof19p+a1i52eRdJOoMCMy1PEDUljqBw09fb1CiPl+rtW8uVDhN4BX8gtnAJm1bpE+QJ/E+e4s+Ye+8lPqdNB/Rf3Bd1zO4KWN9G2jK+MPHamFPlQjdYftWOtfyT8EJ4gMrr6qveU6STvt6+d/C4q+JIAb31VqxvV6CHXsNIH0BNgTLlgUNNNUAAAAASUVORK5CYII=", 933 | "text/latex": [ 934 | "$\\displaystyle x y$" 935 | ], 936 | "text/plain": [ 937 | "x⋅y" 938 | ] 939 | }, 940 | "execution_count": 18, 941 | "metadata": {}, 942 | "output_type": "execute_result" 943 | } 944 | ], 945 | "source": [ 946 | "sqrt(x * y) * sqrt(x * y)" 947 | ] 948 | }, 949 | { 950 | "cell_type": "markdown", 951 | "metadata": {}, 952 | "source": [ 953 | "As an example we let $x=-3$ and $y=2$." 954 | ] 955 | }, 956 | { 957 | "cell_type": "code", 958 | "execution_count": 19, 959 | "metadata": {}, 960 | "outputs": [ 961 | { 962 | "data": { 963 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABkAAAAOCAYAAADaOrdAAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABBklEQVQ4Ea2U6w2CQBCExVCA2oHQgVKKjwrQEvjLP2MJlmCwBCxBSqADAx3gNycYQkSj3CaTfeRu5m73wKmqamTL4jg+drjO1DK3U/wrhchjYwIi4lQkeOWCP1bBgolMpzYCNd8Enyt2hrYL4hU8EpkSlyLtmo2b7CEt+wQkaGMmATw5Igv8FtyBDxJqpn02RNR7WQBp9AzN4AvyEFwGzQQCCRQiJnYagTo/4Tdg7tYLryTNibTmm63Zl7UWmVfUyhXewA4EEtGLWIKfTXuB9omjzzwbr0vD/dSF3IaIeu+9uYa6o5umg0UguUCW4l//LWLdTEMPwfAvXiSyWqRp24zSgZp5HA+oaV2ceQ5pcQAAAABJRU5ErkJggg==", 964 | "text/latex": [ 965 | "$\\displaystyle -6$" 966 | ], 967 | "text/plain": [ 968 | "-6" 969 | ] 970 | }, 971 | "execution_count": 19, 972 | "metadata": {}, 973 | "output_type": "execute_result" 974 | } 975 | ], 976 | "source": [ 977 | "sqrt(-3 * 2) * sqrt(-3 * 2)" 978 | ] 979 | }, 980 | { 981 | "cell_type": "markdown", 982 | "metadata": {}, 983 | "source": [ 984 | "The result is so because $\\sqrt{-3 \\times 2} = \\sqrt{-6} = \\sqrt{6 \\left( -1 \\right)} = \\sqrt{6} \\sqrt{-1} = \\sqrt{6}i$ and $\\left( \\sqrt{6}i \\right)^{2} = 6 i^{2} = -6$." 985 | ] 986 | }, 987 | { 988 | "cell_type": "markdown", 989 | "metadata": {}, 990 | "source": [ 991 | "Note that in the case of a constant, we would evaluate the constant as given and $\\sqrt{\\left( -3 \\right)^{2}} = \\sqrt{9}$." 992 | ] 993 | }, 994 | { 995 | "cell_type": "code", 996 | "execution_count": 20, 997 | "metadata": {}, 998 | "outputs": [ 999 | { 1000 | "data": { 1001 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAOCAYAAAAWo42rAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA2UlEQVQoFXWS4Q2CQAyFwTiArOAIRjdgBF1BRjD+4y8j6Ao6AiOoq8gG+H0ndwGiLylt3732rg153/eZqOt6jatCkmUrvHkD38rlCkk8kIxCuT3cDTsQ3xcE4qgNh4HgEzrhzxJR+CLuBpO3o3nC0gjS6iKxX86rxcVP7GicQGFJ0mAV8dWD0NFAQG5winaYz3lgAWHqmIw9RZOp/wotQvzGuboivNErNQ9niFeXcZgngidiq38iDuPOWoST3cFth6o2Ck/zNhQ5jDe4oi4NQ+JaDqOCNXH6KT7nF1G9okQFwwAAAABJRU5ErkJggg==", 1002 | "text/latex": [ 1003 | "$\\displaystyle 3$" 1004 | ], 1005 | "text/plain": [ 1006 | "3" 1007 | ] 1008 | }, 1009 | "execution_count": 20, 1010 | "metadata": {}, 1011 | "output_type": "execute_result" 1012 | } 1013 | ], 1014 | "source": [ 1015 | "sqrt((-3)**2)" 1016 | ] 1017 | }, 1018 | { 1019 | "cell_type": "markdown", 1020 | "metadata": {}, 1021 | "source": [ 1022 | "There can be more than one term used when distributing. In the next problems we see that we can distribute a group of terms over a group of terms." 1023 | ] 1024 | }, 1025 | { 1026 | "cell_type": "markdown", 1027 | "metadata": {}, 1028 | "source": [ 1029 | "__Problem 4.3.10__ Simplify the expression in __Equation 4.3.18__ by distribution." 1030 | ] 1031 | }, 1032 | { 1033 | "cell_type": "markdown", 1034 | "metadata": {}, 1035 | "source": [ 1036 | "$$\n", 1037 | "\\left( 3x + 4 \\right) \\left( 2x - 1 \\right)\n", 1038 | "\\tag{Equation 4.3.18}\n", 1039 | "$$" 1040 | ] 1041 | }, 1042 | { 1043 | "cell_type": "markdown", 1044 | "metadata": {}, 1045 | "source": [ 1046 | "The result is shown in __Equation 4.3.19__." 1047 | ] 1048 | }, 1049 | { 1050 | "cell_type": "markdown", 1051 | "metadata": {}, 1052 | "source": [ 1053 | "$$\n", 1054 | "\\begin{align*}\n", 1055 | "&\\left( 3x + 4 \\right) \\left( 2x - 1 \\right) \\\\ \\\\\n", 1056 | "= &3x \\left( 2x - 1 \\right) + 4 \\left( 2x - 1 \\right) \\\\ \\\\\n", 1057 | "= &3x \\cdot 2x - 3x \\cdot 1 + 4 \\cdot 2x - 4 \\cdot 1 \\\\ \\\\\n", 1058 | "= &6x^{2} - 3x + 8x - 4 \\\\ \\\\\n", 1059 | "= &6x^{2} + 5x - 4\n", 1060 | "\\end{align*}\n", 1061 | "\\tag{Equation 4.3.19}\n", 1062 | "$$" 1063 | ] 1064 | }, 1065 | { 1066 | "cell_type": "markdown", 1067 | "metadata": {}, 1068 | "source": [ 1069 | "We note that each of the terms $3x$ and $4$ in the first set of parentheses are distributed over each of the terms $2x$ and $-1$ in the second set of parentheses. The signs are important. The $3x$ is distributed over $2x$ and $-1$ and the $4$ is distributed over $2x$ and $-1$." 1070 | ] 1071 | }, 1072 | { 1073 | "cell_type": "markdown", 1074 | "metadata": {}, 1075 | "source": [ 1076 | "We verify the result using the `expand` method in `sympy`." 1077 | ] 1078 | }, 1079 | { 1080 | "cell_type": "code", 1081 | "execution_count": 21, 1082 | "metadata": {}, 1083 | "outputs": [ 1084 | { 1085 | "data": { 1086 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHMAAAAVCAYAAAB17tGhAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAD6UlEQVRoBe2Z7VEbMRBADUMBDnRAOuCjgkAHIVQAdBCGX/CPgQ6ACgLpIFCBgQ6ggxB3QN4T0o18PgZ8nPF5YGcWrXal1a5Wu9KZmcfHx8644ODgoIvuvah/MbZb8PvjWvMj650bs/NHBG4nrQF9An0Dfk28z7a5HZhtTlWlpm0CuJZJjqAX4S1lvE+yoR0YdzDNyuuGbP1U89IOeGe+F+7v7x+Bd++1Xnkd1l6q4HXhL5b509gfujMpgZbCHH7Bu80ZdehYWr8zd7nO/IbmXGGHj7Lkj7QwSZueLKjxN+7pDm14lxTBhOFr8wLchb5UN6198U0PlqjbQ7IMPcmX7AM2CN7Z9+Bv8HDCNmFCbTA26WB2imDCVGAWhkBG9Z5cna4NMZAekHWVxL7tyHqZ42PKB9RpTYNumbtRc26rpuHHz7JBIZgILH+e1m/5APghADlvFJr5ZrufIwYzvWAtCbuj6MnGerhSaczYH4uMe2mFEwtIr1k3uM+gAWExqj7hN6XZZJvQz5Wm16lv4XTO3GQPh6pTKrMr+HQfI74J/Rf0nryAl5fdDv0u/G1QWAW3QDPQeUKPMd5Fjv1i2ybAJm3XhwVQu70zi3uHvna/2kfHvydgm+XVajcEKTM1XlhhsCXxGDRbDaYlOAd/1VF+DLMHnoFr9C2d6im/hmG1BrTvPNqvveINfatHDq30ETs9fFbQyvfGLIIUyCXocuqeM/ksjaH1VOfB6tM32GnefElOtz2A/eugNgeAdlOsPMVJb7mPfoakvX5yIvubyqysqmh7zxlAy7BOX8cNgAzg95kvxLBBtI28FNHj5pazxQU9LB3k4btKOoO6L1X9trL4SpZ+s4/oMUGuQNvXwgbzBsp9PhGZcSgOXS5L9ByDTFv7xYlNwqw1vTuMKy/2A/ZhNq4RknWqguX6VgE33RI/EjDnDxPmaZ/7gSBsPPI3+4gO9/K5dUay28Hoc/+7tFUJV+hLmWnWhYAVkkFiSAmKzRw3IDx2HA4vbYjOtA2sLg8VRqVsLwdRf9rio7FZxR5/C8jBzz0Pt/z7FEzTtzzQSZ4uM/cSNFCO8XFg8M2e8mW8h8xHRRvh9BnbDJj+dJC30kfs0r5go3YmgP8P2tiE621WAR2zS2bxuIHWMcuonx6CTosPUTZwyuEp64FthRNsHLhz6KdfUdJdP20+GiMxwIz/HUiAcwYzCS0/xTcYMvnK78AOfT9PvMP8lciHkkEuSi79xiGuV+vO1BjmW65S5dA/D6SfYn1a5RP3UTteAuz0UOqLh09w33sDwQzsFv/BidoPoBa71Zhpocw2pm38isygkEXjX2r6VvgP89jk1ZSUyAIAAAAASUVORK5CYII=", 1087 | "text/latex": [ 1088 | "$\\displaystyle 6 x^{2} + 5 x - 4$" 1089 | ], 1090 | "text/plain": [ 1091 | " 2 \n", 1092 | "6⋅x + 5⋅x - 4" 1093 | ] 1094 | }, 1095 | "execution_count": 21, 1096 | "metadata": {}, 1097 | "output_type": "execute_result" 1098 | } 1099 | ], 1100 | "source": [ 1101 | "# Verify the result of Problem 4.3.9\n", 1102 | "((3 * x + 4) * (2 * x - 1)).expand()" 1103 | ] 1104 | }, 1105 | { 1106 | "cell_type": "markdown", 1107 | "metadata": {}, 1108 | "source": [ 1109 | "__Homework 4.3.8__ Simplify the expression in $\\left( 2x - 3 \\right) \\left( 3x + 4 \\right)$ by distribution." 1110 | ] 1111 | }, 1112 | { 1113 | "cell_type": "markdown", 1114 | "metadata": {}, 1115 | "source": [ 1116 | "__Problem 4.3.11__ Simplify the expression in __Equation 4.3.20__ by distribution." 1117 | ] 1118 | }, 1119 | { 1120 | "cell_type": "markdown", 1121 | "metadata": {}, 1122 | "source": [ 1123 | "$$\n", 1124 | "\\left( 3x + 4 \\right)^{2}\n", 1125 | "\\tag{Equation 4.3.20}\n", 1126 | "$$" 1127 | ] 1128 | }, 1129 | { 1130 | "cell_type": "markdown", 1131 | "metadata": {}, 1132 | "source": [ 1133 | "The result is shown in __Equation 4.3.21__ wehere we start by squaring the parentheses." 1134 | ] 1135 | }, 1136 | { 1137 | "cell_type": "markdown", 1138 | "metadata": {}, 1139 | "source": [ 1140 | "$$\n", 1141 | "\\begin{align*}\n", 1142 | "&\\left( 3x + 4 \\right)^{2} \\\\ \\\\\n", 1143 | "= &\\left( 3x + 4 \\right) \\left( 3x + 4 \\right) \\\\ \\\\\n", 1144 | "= &3x \\left( 3x + 4 \\right) + 4 \\left( 3x + 4 \\right) \\\\ \\\\\n", 1145 | "= &3x \\cdot 3x + 3x \\cdot 4 + 4 \\cdot 3x + 4 \\cdot 4 \\\\ \\\\\n", 1146 | "= &9x^{2} + 12x + 12x + 16 \\\\ \\\\\n", 1147 | "= &9x^{2} + 24x + 16\n", 1148 | "\\end{align*}\n", 1149 | "\\tag{Equation 4.3.21}\n", 1150 | "$$" 1151 | ] 1152 | }, 1153 | { 1154 | "cell_type": "markdown", 1155 | "metadata": {}, 1156 | "source": [ 1157 | "The result is confirmed using `sympy`." 1158 | ] 1159 | }, 1160 | { 1161 | "cell_type": "code", 1162 | "execution_count": 22, 1163 | "metadata": {}, 1164 | "outputs": [ 1165 | { 1166 | "data": { 1167 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIcAAAAVCAYAAABsSf1CAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE50lEQVRoBe2Z63ETMRCAjScFhFABSQcQOggdBK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lA4tskRkjsa7zPqHtJe0lQL3NviIw6HrqH4KtyM9lsyF2a/wfrqX3zzcyNjnZBvcpTSXFGDN0rrgjF7lLMy2OtxrMpCagro1HcPd4hxBaWGzyKmHtegjaHr8Ni0Vn85Dcyz+Y730IQC86WB74JIx6OsUgvgeY5+bGtSDTindbNOuUdZRFxadIXcta/QvknMgrAqzsLxNPxkWrKEVOv3cnccqx6fHg/V6PbCOsheMG4pjzWAA3jSyxm/zqPxvsiypUq+Zhv6DsUGSHAqsbtZaF/Dv09kOAkjJ3tr1NDkHBD2o/TuHGy3MIn3qKDYrW5XTWA/NuTPaIAH+lFGZNHK7pjiANuupUl5bwLroIn6KsFabBPNi5LUQVxcGewoWsDJaKqQPlPJfWRe5CQgllO9diXmja77ksZ8+RpzvtkXMd8bliXHNqiHft1DNwV75npZGLWZThqx5hqYTuUdnEJTPALDC700Xy8gJXyP2GwSCfGtPA9wM/5G5xtcJY+UIm+tEL6GlhFCcA+LgAaZ1xoWcY/DCVQwORc5xxdM6dCcwafvfYRBy/gT+6SVFG1CauAAAAABJRU5ErkJggg==", 1168 | "text/latex": [ 1169 | "$\\displaystyle 9 x^{2} + 24 x + 16$" 1170 | ], 1171 | "text/plain": [ 1172 | " 2 \n", 1173 | "9⋅x + 24⋅x + 16" 1174 | ] 1175 | }, 1176 | "execution_count": 22, 1177 | "metadata": {}, 1178 | "output_type": "execute_result" 1179 | } 1180 | ], 1181 | "source": [ 1182 | "((3 * x + 4)**2).expand()" 1183 | ] 1184 | }, 1185 | { 1186 | "cell_type": "markdown", 1187 | "metadata": {}, 1188 | "source": [ 1189 | "__Homework 4.3.9__ Expand the expression in $\\left( x - 9 \\right)^{2}$ by distribution." 1190 | ] 1191 | }, 1192 | { 1193 | "cell_type": "markdown", 1194 | "metadata": {}, 1195 | "source": [ 1196 | "In the next problem, we see an example with more than two terms in the set of parenthesis that we are distributing over." 1197 | ] 1198 | }, 1199 | { 1200 | "cell_type": "markdown", 1201 | "metadata": {}, 1202 | "source": [ 1203 | "__Problem 4.3.12__ Simplify the expression in __Equation 4.3.22__ by distribution." 1204 | ] 1205 | }, 1206 | { 1207 | "cell_type": "markdown", 1208 | "metadata": {}, 1209 | "source": [ 1210 | "$$\n", 1211 | "\\left( 2x - 4 \\right) \\left( x^{2} + x - 1 \\right)\n", 1212 | "\\tag{Equation 4.3.22}\n", 1213 | "$$" 1214 | ] 1215 | }, 1216 | { 1217 | "cell_type": "markdown", 1218 | "metadata": {}, 1219 | "source": [ 1220 | "The result is shown in __Equation 4.3.23__." 1221 | ] 1222 | }, 1223 | { 1224 | "cell_type": "markdown", 1225 | "metadata": {}, 1226 | "source": [ 1227 | "$$\n", 1228 | "\\begin{align*}\n", 1229 | "&\\left( 2x - 4 \\right) \\left( x^{2} + x - 1 \\right) \\\\ \\\\\n", 1230 | "= &2x \\left( x^{2} + x - 1 \\right) - 4 \\left( x^{2} + x - 1 \\right) \\\\ \\\\\n", 1231 | "= &2x \\cdot x^{2} + 2x \\cdot x - 2x \\cdot 1 - 4 \\cdot x^{2} - 4 \\cdot x - 4 \\cdot -1 \\\\ \\\\\n", 1232 | "= &2x^{3} + 2x^{2} - 2x - 4x^{2} - 4x + 4 \\\\ \\\\\n", 1233 | "= &2x^{3} - 2x^{2} - 6x + 4\n", 1234 | "\\end{align*}\n", 1235 | "\\tag{Equation 4.3.23}\n", 1236 | "$$" 1237 | ] 1238 | }, 1239 | { 1240 | "cell_type": "markdown", 1241 | "metadata": {}, 1242 | "source": [ 1243 | "The result is confirmed using `sympy`." 1244 | ] 1245 | }, 1246 | { 1247 | "cell_type": "code", 1248 | "execution_count": 23, 1249 | "metadata": {}, 1250 | "outputs": [ 1251 | { 1252 | "data": { 1253 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKoAAAAVCAYAAADW6nUiAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE60lEQVRoBe2avVIUQRCAV7wHQHwDTY1Qc6qEN0B9AjQ00zIjoyDTDMjMFDLNxCoCjVAzQ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v6DKDuV3VseifZDfrZ5OMpYElwNh+jPbzgloFk1XGeKm+jJOMlWpMhSHoyjfwyI/vlgM1vrBAe+aWCK0aCA9gspEY1dWyjoHvJmgEuqijNgO1V0ga5xjOozVj3th+hMegQJS3J6yf5/KT+BxZcjJzlcuvS4M2WT4vz6hxkZu0edRHJhltiQnP7iYzXrg4yQ1ayIC0FxnLqVMDZNOQXdXRbBmC8RwDl3zoHOzRBj8q811ksRQrQrgnRfpxCFQeJDq5enkKNSh0g1BGFuEaxB1VLXz9FFV9n2ntAGTruo4enVVna3xPJ311ALbOj8qFfGIJoP+CoMwhcfboGNEqKLFaJyxD8/ZowLr7vE2q7AmYAzTHjnJCyzrIdxl09PKrD00mIWHQ6itLND8jCvrpf/GjsosBevx9D+rI9H00DMQ/qZ4x4r2RqWSGAbyh+Q8mBrbF+gn9vAxwTsvgMuiY4QN/hTJQU8LxcnOP5//Gj1F241EwUZpEjxr/N7+w3OzPpbAAQTXyZWpYw8wNO3E2b2aBISzQZ45YO/wBIe+Qm6aXmD4AAAAASUVORK5CYII=", 1254 | "text/latex": [ 1255 | "$\\displaystyle 2 x^{3} - 2 x^{2} - 6 x + 4$" 1256 | ], 1257 | "text/plain": [ 1258 | " 3 2 \n", 1259 | "2⋅x - 2⋅x - 6⋅x + 4" 1260 | ] 1261 | }, 1262 | "execution_count": 23, 1263 | "metadata": {}, 1264 | "output_type": "execute_result" 1265 | } 1266 | ], 1267 | "source": [ 1268 | "# Expand the expression in Problem 4.3.12 using the expand method\n", 1269 | "((2 * x - 4) * (x**2 + x - 1)).expand()" 1270 | ] 1271 | }, 1272 | { 1273 | "cell_type": "markdown", 1274 | "metadata": {}, 1275 | "source": [ 1276 | "__Homework 4.3.10__ Simplify the expression in $\\left( 3x - 3 \\right) \\left( x^{2} - x + 2 \\right)$ by distribution." 1277 | ] 1278 | }, 1279 | { 1280 | "cell_type": "markdown", 1281 | "metadata": {}, 1282 | "source": [ 1283 | "Next we investigate an example where we have to distribute three groups of terms." 1284 | ] 1285 | }, 1286 | { 1287 | "cell_type": "markdown", 1288 | "metadata": {}, 1289 | "source": [ 1290 | "__Problem 4.3.13__ Simplify the expression in __Equation 4.3.24__ by distribution." 1291 | ] 1292 | }, 1293 | { 1294 | "cell_type": "markdown", 1295 | "metadata": {}, 1296 | "source": [ 1297 | "$$\n", 1298 | "\\left( a + b \\right)^{3}\n", 1299 | "\\tag{Equation 4.3.24}\n", 1300 | "$$" 1301 | ] 1302 | }, 1303 | { 1304 | "cell_type": "markdown", 1305 | "metadata": {}, 1306 | "source": [ 1307 | "The solution is shown in __Equation 4.3.25__ where we start by writing the term in parenthesis three times." 1308 | ] 1309 | }, 1310 | { 1311 | "cell_type": "markdown", 1312 | "metadata": {}, 1313 | "source": [ 1314 | "$$\n", 1315 | "\\begin{align*}\n", 1316 | "&\\left( a + b \\right)^{3} \\\\ \\\\\n", 1317 | "= &\\left( a + b \\right) \\left( a + b \\right) \\left( a + b \\right) \\\\ \\\\\n", 1318 | "= &\\left( a + b \\right) \\left( a^{2} + ab + ba + b^{2} \\right) \\\\ \\\\\n", 1319 | "= &a \\left( a^{2} + ab + ba + b^{2} \\right) + b \\left( a^{2} + ab + ba + b^{2} \\right) \\\\ \\\\\n", 1320 | "= &a \\cdot a^{2} + a \\cdot ab + a \\cdot ba + a \\cdot b^{2} + b \\cdot a^{2} + b \\cdot ab + b \\cdot ba + b \\cdot b^{2} \\\\ \\\\\n", 1321 | "= &a^{3} + a^{2}b + aba + ab^{2} + ba^{2} + bab + b^{2}a + b^{3} \\\\ \\\\\n", 1322 | "= &a^{3} + a^{2}b + a^{2}b + ab^{2} + a^{2}b + ab^{2} + ab^{2} + b^{3} \\\\ \\\\\n", 1323 | "= &a^{3} + 3a^{2}b + 3ab^{2} + b^{3}\n", 1324 | "\\end{align*}\n", 1325 | "\\tag{Equation 4.3.25}\n", 1326 | "$$" 1327 | ] 1328 | }, 1329 | { 1330 | "cell_type": "markdown", 1331 | "metadata": {}, 1332 | "source": [ 1333 | "In __Equation 4.3.27__ we consider the last two groups of terms first, completed that distribution, and then distributed the first group of terms. The result is confirmed in the code cell below." 1334 | ] 1335 | }, 1336 | { 1337 | "cell_type": "code", 1338 | "execution_count": 24, 1339 | "metadata": {}, 1340 | "outputs": [ 1341 | { 1342 | "data": { 1343 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMEAAAAVCAYAAAD/7YqlAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFJ0lEQVRoBe2a7VHcMBCGj5sr4Eg6IB0QUkGgA0gqADqA4R//GOgAUgEfHZBUEKAEUkEYOiDvY7Qen+7OluWPsy+3M7Lktb3afbUrrXS39vb2NihDp6enG3p/W+VFhfYXlTPxn1T3nmTHWEacOEOwD9oX//W9ubqCQN9wkr5z/XYUMaTn+uZZQq8cGEeqf6msc78EdC7bDs0OtS/VflT5ZLxVnSDQN5zm+u0wYkDP9M115ruParMqLAsdyPFZ6YwAb0O8TWOs6gSBvuE0129LrwRyBj/t2RUkOMqyEKvAw7IY06AdvcIpz2/Xyu4JDFQJJQ36rnKt9oXxl62WbQT4rupVOpQzuH3BSXpO+W10EICHBLKJvFW5V3shgaB+2fAwK0Howz356k8YVUgySIGw77Pa6cZYbbN7S89edL/QAFH/tWJQ1j69PxOnKtiX+TZCXxu/xG8rBQGKOgDYOOIofqpUxpbS7zrj/Q0a6RmOu6fnd6WFug/0LY7Fphg5aQBk5YmP3Q+qLQizj1tpq28GtCkMCu1T/4U4tQKEOpEuhfqaLnqXwE38ttSeQB8C+B+Vr2qbw5uDMCsaT80wkhw2oWw8k9OmsK/Stw7UYoNGRJvD2wrAMafx0g9CGpLFwB6r3uF9d0/97H0PkGcer/St5HYOA2dErn0OlxCcCjGpiIHJn6mvZOf67dC+DqklDId/Uck6AwMI/0YlhlCQEkMEHX1TEnI62m3pWt/bzHap9iZFQo5VsDsl8bEbsqB7v4u7dgoDTCiyT8+DcCoBRxUMcvWVrvjHXL8dlVDSXt1T40SC/zoGP5ZN5Mz2YtO1dMABJ36fEI90CCKViSGWSAaEOiXJ9VMeVgl+LwHghVFDGGBPkX2hOLWFTZG+c/12IggEKNHNaQgzPU5OOsHJSLrpVZvZl9I5km7Mzuh/qPZUeiVeiH0TQZVjJH09SSanDRCTASdlUSlYIqGGi/qvjIFTI9c+9ROKUw1WBYko0neu3w5NvAOP6CbHo+D4zKZsupgZO0vSj7QFZ2S2xtgHX1k9B6Ra7HN4kCYRVFe6B6t9lVu14bVO6rc2DLpoXx6gVfVNgsAJ4UQF58/m+7QXvuTnAcAz6cyMfKHCknet8qi2pUUDtQniOu0joCAOCJJ0yNW0036TN1q6qP86MeicfQUwVtJ35ISTQowFpJ9CILyW5V2yWVVMWddtUn3gqud+zg2bgcWxg0nv36ngjMzK665dt33kn+iWBEBGubHa/I1kJun9vmAQZd9Moz1mQxhU0teC4Jt0nTjlkLIMKEv7vWdH1K3kzXLygfjMnByRpvuO0A70DSkJMvw9CukQAWdBXLd9JpfuE5IO8KDf79X0Ve/0BYMo+6YtnuY0gYF6qaTvUErh7BTf2XGcgZ5PBAe8DhE5PqkP+s+khuxjcvCd3VastvFqAoMu2TdzXD1mJX2HGWHZvQDsZImhIUfihIiOukavUsjSn6xuW+4m65B125fKc4HGpMGpFDq1SU1h0BX7QrGM1peVABBxltTJxSNFIdWwU5Yd8dJOxO8K8SPWxArmdB+LnzhkQ/axT7JAAws23Tfqy99T8axpagKDLtkXgl8lfUeuB5byHxrEI9Vs7DhhYSXgeBRe7A9P+rQ5wulUtlWy+hHMBG12Fajbvn31AV78cY6AYxO+iAAY0K9K3Rh0xj5hG0KV9K38B7oQDfPe0QBGb4zz5Pbp2QqD95RbYxZ1QFJ1rIdVBdTwPekY5X+mFQbef8DadIZ/ICM/M80SXI0AAAAASUVORK5CYII=", 1344 | "text/latex": [ 1345 | "$\\displaystyle a^{3} + 3 a^{2} b + 3 a b^{2} + b^{3}$" 1346 | ], 1347 | "text/plain": [ 1348 | " 3 2 2 3\n", 1349 | "a + 3⋅a ⋅b + 3⋅a⋅b + b " 1350 | ] 1351 | }, 1352 | "execution_count": 24, 1353 | "metadata": {}, 1354 | "output_type": "execute_result" 1355 | } 1356 | ], 1357 | "source": [ 1358 | "# Expand the expression in Problem 4.3.13 using the expand method\n", 1359 | "((a + b)**3).expand()" 1360 | ] 1361 | }, 1362 | { 1363 | "cell_type": "markdown", 1364 | "metadata": {}, 1365 | "source": [ 1366 | "__Homework 4.3.11__ Simplify the expression in $\\left( x - 3 \\right)^{3}$ by distribution." 1367 | ] 1368 | }, 1369 | { 1370 | "cell_type": "markdown", 1371 | "metadata": {}, 1372 | "source": [] 1373 | } 1374 | ], 1375 | "metadata": { 1376 | "kernelspec": { 1377 | "display_name": "mathematics", 1378 | "language": "python", 1379 | "name": "python3" 1380 | }, 1381 | "language_info": { 1382 | "codemirror_mode": { 1383 | "name": "ipython", 1384 | "version": 3 1385 | }, 1386 | "file_extension": ".py", 1387 | "mimetype": "text/x-python", 1388 | "name": "python", 1389 | "nbconvert_exporter": "python", 1390 | "pygments_lexer": "ipython3", 1391 | "version": "3.10.9" 1392 | }, 1393 | "orig_nbformat": 4 1394 | }, 1395 | "nbformat": 4, 1396 | "nbformat_minor": 2 1397 | } 1398 | -------------------------------------------------------------------------------- /Lecture05Factoring.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# 5 | Factoring" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | ">Dr J H Klopper

\n", 15 | ">Department of Biostatistics and Bioinformatics
\n", 16 | ">Milken Institute School of Public Health
\n", 17 | ">George Washington University" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": {}, 23 | "source": [ 24 | "

This chapter of Algebra for Health Data Science by Dr JH Klopper is licensed under Attribution-NonCommercial-NoDerivatives 4.0 International

" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "- Watch the pencil and paper video lecture [HERE](https://youtu.be/0bgGgAgfKYo)\n", 32 | "\n", 33 | "- Watch the Python video lecture [HERE](https://youtu.be/WWQB73waZAk)" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "## 5.1 Packages used in this chapter" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": {}, 46 | "source": [ 47 | "Below, we import only the functions that are used in this chapter instead of importing the entire package. To do this we use the `from` and `import` keywords." 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 1, 53 | "metadata": {}, 54 | "outputs": [], 55 | "source": [ 56 | "from sympy import init_printing, symbols, Rational, gcd" 57 | ] 58 | }, 59 | { 60 | "cell_type": "markdown", 61 | "metadata": {}, 62 | "source": [ 63 | "The `init_printing` function is used to display the output of `sympy` code in mathematical notation." 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 2, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "init_printing()" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## 5.2 Introduction" 80 | ] 81 | }, 82 | { 83 | "cell_type": "markdown", 84 | "metadata": {}, 85 | "source": [ 86 | "In the previous chapter, we considered the expansion of expressions through the use of the distribution. In this chapter, we will consider the reverse process, that of factoring. Factoring is the process of breaking down an expression into its constituent parts. This is a very important process in algebra, as it allows us to simplify expressions and solve equations." 87 | ] 88 | }, 89 | { 90 | "cell_type": "markdown", 91 | "metadata": {}, 92 | "source": [ 93 | "## 5.3 Polynomials" 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "Until now we have explored many expressions. Many of them have been polyomials. In this section, we formely define polynomials." 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "__Definition 5.3.1__ A __polynomial__ is a mathematical expression of constants and variables combined using addition, subtraction, multiplication, and non-negative integer exponents, defined in __Equation 5.3.1__, where $a_{i}$ are constants and $x$ is a variable." 108 | ] 109 | }, 110 | { 111 | "cell_type": "markdown", 112 | "metadata": {}, 113 | "source": [ 114 | "$$\n", 115 | "\\begin{equation}\n", 116 | "a_{n}x^{n} + a_{n-1}x^{n-1} + \\cdots + a_{2}x^{2} + a_{1}x + a_{0}\n", 117 | "\\end{equation}\n", 118 | "\\tag{Equation 5.3.1}\n", 119 | "$$" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "__Definition 5.3.2__ The constants $a_{i}$ in __Equation 5.3.1__ are called the __coefficients__ of the polynomial." 127 | ] 128 | }, 129 | { 130 | "cell_type": "markdown", 131 | "metadata": {}, 132 | "source": [ 133 | "__Defintion 5.3.3__ The __degree__ of the polynomial is the highest exponent of the variable $x$." 134 | ] 135 | }, 136 | { 137 | "cell_type": "markdown", 138 | "metadata": {}, 139 | "source": [ 140 | "In the case that $a_{n} \\neq 0$ in __Equation 5.3.1__, the polynomial is said to be of degree $n$." 141 | ] 142 | }, 143 | { 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "__Problem 5.3.1__ Determine of the expression in __Equation 5.3.2__ is a polynomial. If so, determine the degree of the polynomial." 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "$$\n", 155 | "\\begin{equation}\n", 156 | "3x^{4} + 2x^{3} + 5x^{2} + 7x + 1\n", 157 | "\\end{equation}\n", 158 | "\\tag{Equation 5.3.2}\n", 159 | "$$" 160 | ] 161 | }, 162 | { 163 | "cell_type": "markdown", 164 | "metadata": {}, 165 | "source": [ 166 | "The expression in __Equation 5.3.2__ is indeed a polynomial as follows the definition in __Equation 5.3.1__. The highest power of the variable $x$ is $4$ and hence the polynomial is of degree 4 or a $4^{\\text{th}}$-degree polynomial." 167 | ] 168 | }, 169 | { 170 | "cell_type": "markdown", 171 | "metadata": {}, 172 | "source": [ 173 | "__Definition 5.3.4__ A __quadratic polynomial__ is a polynomial of degree $2$." 174 | ] 175 | }, 176 | { 177 | "cell_type": "markdown", 178 | "metadata": {}, 179 | "source": [ 180 | "__Definition 5.3.5__ A __cubic polynomial__ is a polynomial of degree $3$." 181 | ] 182 | }, 183 | { 184 | "cell_type": "markdown", 185 | "metadata": {}, 186 | "source": [ 187 | "__Definition 5.3.6__ A __quartic polynomial__ is a polynomial of degree $4$." 188 | ] 189 | }, 190 | { 191 | "cell_type": "markdown", 192 | "metadata": {}, 193 | "source": [ 194 | "__Defintion 5.3.7__ A __quintic polynomial__ is a polynomial of degree $5$." 195 | ] 196 | }, 197 | { 198 | "cell_type": "markdown", 199 | "metadata": {}, 200 | "source": [ 201 | "Note that polynomials as defined in __Equation 5.3.1__ only contain a single variable." 202 | ] 203 | }, 204 | { 205 | "cell_type": "markdown", 206 | "metadata": {}, 207 | "source": [ 208 | "## 5.4 Factoring common elements" 209 | ] 210 | }, 211 | { 212 | "cell_type": "markdown", 213 | "metadata": {}, 214 | "source": [ 215 | "In the simplest cases of an expression, we can factor out a common element, whether they are constants or variable. We start by a common variable among the terms of an expression." 216 | ] 217 | }, 218 | { 219 | "cell_type": "markdown", 220 | "metadata": {}, 221 | "source": [ 222 | "__Problem 5.4.1__ Factor out the common variable $x$ from the expression in __Equation 5.4.1__." 223 | ] 224 | }, 225 | { 226 | "cell_type": "markdown", 227 | "metadata": {}, 228 | "source": [ 229 | "$$\n", 230 | "\\begin{equation}\n", 231 | "x^{2} + 3x\n", 232 | "\\end{equation}\n", 233 | "\\tag{Equation 5.4.1}\n", 234 | "$$" 235 | ] 236 | }, 237 | { 238 | "cell_type": "markdown", 239 | "metadata": {}, 240 | "source": [ 241 | "We note that the variable $x$ is in both terms of the exprerssion and can be factorized as shown in __Equation 5.4.2__." 242 | ] 243 | }, 244 | { 245 | "cell_type": "markdown", 246 | "metadata": {}, 247 | "source": [ 248 | "$$\n", 249 | "\\begin{equation}\n", 250 | "x^{2} + 3x = x(x + 3)\n", 251 | "\\end{equation}\n", 252 | "\\tag{Equation 5.4.2}\n", 253 | "$$" 254 | ] 255 | }, 256 | { 257 | "cell_type": "markdown", 258 | "metadata": {}, 259 | "source": [ 260 | "Distribution of the solution can be used to confirm the result as $x(x+3) = x^{2}+3x$. We can also use the `factor` method in `sympy` to confirm the result. We start by defining the mathematical symbol $x$ and assign ot to the variable `x`." 261 | ] 262 | }, 263 | { 264 | "cell_type": "code", 265 | "execution_count": 3, 266 | "metadata": {}, 267 | "outputs": [], 268 | "source": [ 269 | "# Define the symbol x\n", 270 | "x = symbols('x')" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 4, 276 | "metadata": {}, 277 | "outputs": [ 278 | { 279 | "data": { 280 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE0AAAAVCAYAAAAD1GMqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADM0lEQVRYCdWY7XETMRCGD8YFOJRgOgikAuwOgqmAuAOY/LL/MaEDQgVM0oFDBfnogJTgcQfmfWTpZn2RL3N3ezjszFrSavVKu7erDxebzabw5vl8PvLGPBRezpbXhTMtFosvgjx2hj0k3CjaVK7hFV/QiwR+KqwTlV+9MPvE0TpHwp/FOYYqaV9IfhNloVCbQFirvETg5jQBMulvle8AfukU14uDktMK1fnoV+KPql9bG9S+V/uDyrVnel4I9IedqO+6DBiLz1rOw7gzjcdRiVKEnSeBKbENGwtPp021gBC+ZqK+q0Q33IYeNGgdOYzX+mlnKdqGjcNBVqOhUEB8rceGww6qrjUTVUd2EdEORPsyBhunpdPwoAQp1E9U/yxmY/wkhm6ls5PnW3H4neg3hbYRb6sdsZ/g9SHQGsfCJf1mqu/LGGyc2PRkU/wOq+NW/FPMnsFJiENDPqvM0XsJ/+Q6oqwLdg1s9y7ZdyzmdORAIGXvalCxcRQiTYOIMOsUcpuUI9qgN2LbH4TmB6euTLusOmCXWH1UtD4cBReqY/O9yienJ/0ibNw6TZU7Kdo9iWvDg2Q4rwCEsoZwatDN6HTFZn72GNKnSsxLf3ltMAqs/7l1G/WAc60x2HGl8ijWrQ4+2h4E6gyeNr1T1b+ZduuqB7Ywck4pJCcyuLGzpTQijQmvFpVV20lPPhBc3cNDcNg9LUwqEJRJt3KAZEM4KOR/CNu6/jCqJXZ+xu5SLquk4rPrNlOhuxrEQdyC0/OBr8qTwabrudp1TyN0OWl3yAl7B9OxsRbWjdZIaYlDDcrdBoi0RyItheIqGknUlCQZ/ZymdUSIc02pkgd2FdOrTRAsLZhsJd2JJq4dVWeiGvb6gSp4lHsJBhZSZsBSzOZLCOPMMlXRydAvyYjWKnlgVzFd2rLpUjyOdiZMsmUiWS7K0MFHM88HO3cYjmqi7p+Q5mp9EDRdoObCoQTTW9LTi7jHZU85rwkyOKRQLo0yqp1FpPP2rur5j6j+5Vzm/un0nOMQWNiEbWluz0jjU3KZ3PfYpf9/JWwqs8htT0veiLl/qrLxhTNhvKRSdvAu5aVQXsH+AqUAC/6ulX6YAAAAAElFTkSuQmCC", 281 | "text/latex": [ 282 | "$\\displaystyle x \\left(x + 3\\right)$" 283 | ], 284 | "text/plain": [ 285 | "x⋅(x + 3)" 286 | ] 287 | }, 288 | "execution_count": 4, 289 | "metadata": {}, 290 | "output_type": "execute_result" 291 | } 292 | ], 293 | "source": [ 294 | "# Factor the polynomial x^2 + 3x\n", 295 | "(x**2 + 3*x).factor()" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "__Homework 5.4.1__ Factor out the common variable $x$ from the expression $x^{3}-2x^{2}+x$." 303 | ] 304 | }, 305 | { 306 | "cell_type": "markdown", 307 | "metadata": {}, 308 | "source": [ 309 | "Some examples of factoring involves the constants. In this case, it is best to look for the greatest common divisor." 310 | ] 311 | }, 312 | { 313 | "cell_type": "markdown", 314 | "metadata": {}, 315 | "source": [ 316 | "__Defintion 5.4.1__ The __greatest common divisor__ (GCD) of two or more integers is the largest positive integer that divides each of the integers." 317 | ] 318 | }, 319 | { 320 | "cell_type": "markdown", 321 | "metadata": {}, 322 | "source": [ 323 | "__Problem 5.4.2__ Factor out the common constants or variables from the expression in __Equation 5.4.3__." 324 | ] 325 | }, 326 | { 327 | "cell_type": "markdown", 328 | "metadata": {}, 329 | "source": [ 330 | "$$\n", 331 | "\\begin{equation}\n", 332 | "6x^{2} + 9y\n", 333 | "\\end{equation}\n", 334 | "\\tag{Equation 5.4.3}\n", 335 | "$$" 336 | ] 337 | }, 338 | { 339 | "cell_type": "markdown", 340 | "metadata": {}, 341 | "source": [ 342 | "There are no common variables. We note that $3$ divides both $6$ and $9$ and is factored out as shown in __Equation 5.4.4__." 343 | ] 344 | }, 345 | { 346 | "cell_type": "markdown", 347 | "metadata": {}, 348 | "source": [ 349 | "$$\n", 350 | "\\begin{equation}\n", 351 | "6x^{2} + 9y = 3(2x^{2} + 3y)\n", 352 | "\\end{equation}\n", 353 | "\\tag{Equation 5.4.4}\n", 354 | "$$" 355 | ] 356 | }, 357 | { 358 | "cell_type": "markdown", 359 | "metadata": {}, 360 | "source": [ 361 | "We verify the result using the `factor` method in `sympy` after defining the mathematical symbol $y$ and assigning them to the variables `y`." 362 | ] 363 | }, 364 | { 365 | "cell_type": "code", 366 | "execution_count": 5, 367 | "metadata": {}, 368 | "outputs": [], 369 | "source": [ 370 | "# Define the symbol y\n", 371 | "y = symbols('y')" 372 | ] 373 | }, 374 | { 375 | "cell_type": "code", 376 | "execution_count": 6, 377 | "metadata": {}, 378 | "outputs": [ 379 | { 380 | "data": { 381 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHgAAAAaCAYAAAB8WJiDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFrElEQVRoBe2Z63EUORCAF5cDMA7BZAAmA8jguIvAkAGU//kfBRkAGdyRAVwEPDKADM7nDHzfJ6sHjXZm2Nmdnd063FWytHr0u1ut8Z3r6+v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XqP0mF5vbQFzNa9dSmidWecHdLoMuGDebOEzq8kqq+LnzE/1zZ6kb3p1b1A06Tmfd64vgkO/lweZKStL07GHRgPn7tE6FTEaWT4APhUo3iYSGHe+W5kPJTROyFwqMtalv+VzY/St/E1mynwpr4FVO3mwHXa8OswzV/QfOWBfwmn+0ecp5d5Vx0Z7MNB5Bj708If0dVGl0f2m7Hnv5fiUqnNFJmGYIBUo8WPP+jH6trgsryJFGbp/XW8iOAxcK3KBElWmivTjtQxNBRYO533IoKVAGk+H8/4rwa9Hr2nyphdbLctjc+e4mTnXokBxat9gjL41bhgsZFO+oYypDnX4mwhmYFSovFKhbtr42y84ajCtpPQpA/Uiv/2EKe1435ZbIiWZUbyTFHQBHp3wA03+TX+XjJt07Z59Angbo2+dwfeuL4J/aL6JhaGsasGZ1tM/G9L2Gf/ArFW3z68hJmfkaDwpeDeLrFVkjaf240Q2tMHY+2JhTSf3k+zbgx9HZx39CbWlynhWDjYnZvbpykCbY84YNGY2Vpph7HVkZnuZtyx1eY81jDpeHC7tmGfCVPo3bekumof85lRQ5BzZxyxRXpvpaxa0h64fn4vxpm7+m7S5xCMwwKB3qUWUAtxCvwYMAIul5zQNbdr9WVC43uzZVQQr0hnNKB7yRvf9soAxR+mG/aZvnaB5Vu2kyAqLwYgR3PXejS23/YoaQJe+PDRuq7bZVZGV2IYZPdR/7qfnzoqy3G7r1oBpufnqF1v+A/f6X/m4t+b1AAAAAElFTkSuQmCC", 382 | "text/latex": [ 383 | "$\\displaystyle 3 \\cdot \\left(2 x^{2} + 3 y\\right)$" 384 | ], 385 | "text/plain": [ 386 | " ⎛ 2 ⎞\n", 387 | "3⋅⎝2⋅x + 3⋅y⎠" 388 | ] 389 | }, 390 | "execution_count": 6, 391 | "metadata": {}, 392 | "output_type": "execute_result" 393 | } 394 | ], 395 | "source": [ 396 | "# Verify the result\n", 397 | "(6 * x**2 + 9 * y).factor()" 398 | ] 399 | }, 400 | { 401 | "cell_type": "markdown", 402 | "metadata": {}, 403 | "source": [ 404 | "__Problem 5.4.3__ Factor out the common term (with constants and or variables) from the expression in __Equation 5.4.5__." 405 | ] 406 | }, 407 | { 408 | "cell_type": "markdown", 409 | "metadata": {}, 410 | "source": [ 411 | "$$\n", 412 | "\\begin{equation}\n", 413 | "216x+450y\n", 414 | "\\end{equation}\n", 415 | "\\tag{Equation 5.4.5}\n", 416 | "$$" 417 | ] 418 | }, 419 | { 420 | "cell_type": "markdown", 421 | "metadata": {}, 422 | "source": [ 423 | "It can be difficult to calculate a GCD. We note the following observations." 424 | ] 425 | }, 426 | { 427 | "cell_type": "markdown", 428 | "metadata": {}, 429 | "source": [ 430 | "- Any integer, is the product of two integers\n", 431 | "- None of the two integers used in the product can be more than half the original integer\n", 432 | "- We only need to consider integers up to the square root of the original integer\n", 433 | "- Any integer is the product of prime numbers\n", 434 | "- The GCD of two numbers is the same as the GCD of the remainder of the division of the larger number by the smaller number and the smaller number." 435 | ] 436 | }, 437 | { 438 | "cell_type": "markdown", 439 | "metadata": {}, 440 | "source": [ 441 | "Instead of considering these arithmetical properties, we calculate the greatest common divisor using the `gcd` function in `sympy`." 442 | ] 443 | }, 444 | { 445 | "cell_type": "code", 446 | "execution_count": 7, 447 | "metadata": {}, 448 | "outputs": [ 449 | { 450 | "data": { 451 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAABMAAAAOCAYAAADNGCeJAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABM0lEQVQ4EZWT0W3CQAyGQ8UAiG5QNoCOABvACG03oOItr4xAGYFsAJ2gohuUEVo2SL8PxQiURHCWrPP99v3ns32dsiyzkDzPh9gbdIR9DDxWsB72Ivas7jfgO7FuFbDG/kWf0Se0TZbEv1062UvWQwvJzGBmAPacxexqgu8VcF9zZNkL2CdaPDQ426ABjkmbUzyF7Iv4KRluUWsVssRYuekGcmuFoFCJm6J/2O+sZiu5eFJmGYes7YcHETMao99ulJRnSmZWNsyMHAc7/1PhSc+0m85fjMakInEu19i7lMx8lnU6CwTWyixtyPguMg4Z7GD6xCsBOwBI2r+XTJIjB61Rk3hZ7ZmPVWS/4YSdPH2dSx8XWEvH49Dxo2NYRMVWe4vtNn2DYhSM86v50f3HIeeP/g9Ii2/N2CFM4AAAAABJRU5ErkJggg==", 452 | "text/latex": [ 453 | "$\\displaystyle 18$" 454 | ], 455 | "text/plain": [ 456 | "18" 457 | ] 458 | }, 459 | "execution_count": 7, 460 | "metadata": {}, 461 | "output_type": "execute_result" 462 | } 463 | ], 464 | "source": [ 465 | "# Return the greatest common divisor of 216 and 450\n", 466 | "gcd(216, 450)" 467 | ] 468 | }, 469 | { 470 | "cell_type": "markdown", 471 | "metadata": {}, 472 | "source": [ 473 | "We note that $18$ is the GCD of $216$ and $450$. This means that both these values can be divided by $18$ without a remainder. Below, we calculate the divisions." 474 | ] 475 | }, 476 | { 477 | "cell_type": "code", 478 | "execution_count": 8, 479 | "metadata": {}, 480 | "outputs": [ 481 | { 482 | "data": { 483 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAACMAAAAOCAYAAACl66WxAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB30lEQVQ4EZ2V0VECMRCGgbEAxA6gA5EKxA60Be1AH+HNwQ7UChztQDpQ6UCsAKUD/L5wuTkzOfTcmc1mN5vsn80maW82m1ak6XR6SP8RHtJfR3uU2Pr0rwr9CPmpjn1R2H4V+M4KpxVyAM+wLbW1J5NJF3kPu7ABBLSPww8w6AK5RZ4gA9F34Uv4hP58a61v8Xlj9Br5pBfS2Nqcv+zQrOEz+ALjA1xHBtanJOaYJUGbzZ2E7zkOXWQAojN956rfqnds/khj/N5ZwN1UyYwYxMztojMGc8f5gn3suk3AGHRZ7CYXNAWZ+rgZSyGlUC8Yx3vpSJ0OCHeWI2usxXhu18Gfsd+A6tdrkpmwcLUhiEA8nnjDqsPVfq9QrJE6anRMuUUs3CdA3eQGG9oO/p0ZAHgDrKG646tiydVKHI9ZW/0LDAC8pj1k+ebElXMSv3g8udqJtmVjMCx8SsABsswI/b6cA1KxeRtzPjEz80ZgCGjBjpBpwQpw11GIyfryhU9piGHBmut28jfF592dx/sfJqO7q2c49+z7aPnPtJCm/Qs2gIFKQn9H8S+rfgcf2I6xLcI7Qyc+5z5M0iM2wTwj74JlC0RA1ktK5RuDv9+Lc19TJ3TB+TGOkH6UygAE2foG2QmuhhDyAVMAAAAASUVORK5CYII=", 484 | "text/latex": [ 485 | "$\\displaystyle 12.0$" 486 | ], 487 | "text/plain": [ 488 | "12.0" 489 | ] 490 | }, 491 | "execution_count": 8, 492 | "metadata": {}, 493 | "output_type": "execute_result" 494 | } 495 | ], 496 | "source": [ 497 | "216 / 18" 498 | ] 499 | }, 500 | { 501 | "cell_type": "code", 502 | "execution_count": 9, 503 | "metadata": {}, 504 | "outputs": [ 505 | { 506 | "data": { 507 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAACMAAAAPCAYAAABut3YUAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACPUlEQVRIDa2VPVIbQRBGhc0BZOkEiNSRDLmqLN0AnDm1bwBFJGUuCJ2h0Bk2IRmiSgFELrgB4gQYZQ7l98Y7W7vDLhI2XfWpf6anu6enNdtYLBaNVTEcDrupL7Ym6KT2f9HXG9BoNOrA9pWhLfAL7GO/0VCgC2xN9GhXlt79Zct/2X+Yed3DN8Ehtpm218BCjjF86PV6Z2A8nU7fYvsGv0IPjugN9E+wNbABfoNT8JG9c/hSwu8apxP4V+JeEe8S/RJu3gc7Y6WfQU442xUT/wBv8gU6gn23oK8sZvGacA8QCHme6ccYBq/46YNbjLHlwZGfCXCznXsJ8hDxeovxfqL0zW8xJp2h1LU6LbIY6Dmyh3YWU4pj0F+niLq2d93Feuk06F6fBbaBXfuS+mArEeurHKhlZx4Rmy3ERPEfFn0M+p31I+CauEb21E9RK1ucP+EUrqlq3cE9NWlxEX0A8oDItthrdgD/l9qPOkMCAztDddeXJrWgDv52so6qZiX6xq7dl4ohoPPQgg+iZ+TYzoHvRB3VzgX7YjerfKJtlhfDhh2ybMLzjiAXT+zLHDcWCwonw7c06EWHTPY6q7oXOzMJxRCoi+M2PB1YC4wtHrPu852Sw2uiZeQceqCU/JT4mM7X/MihnIOqgD5GoQC4fr7M+WuNvIftAGwgh6uA270HYILSNwv9Frsxwiuc+d5he498YzE6VLUPczkgG0JBLkC2164ZPBSiUUI35gSeF57ZLdTPj/5+KLdB/k79AetsOvl1jN6vAAAAAElFTkSuQmCC", 508 | "text/latex": [ 509 | "$\\displaystyle 25.0$" 510 | ], 511 | "text/plain": [ 512 | "25.0" 513 | ] 514 | }, 515 | "execution_count": 9, 516 | "metadata": {}, 517 | "output_type": "execute_result" 518 | } 519 | ], 520 | "source": [ 521 | "450 / 18" 522 | ] 523 | }, 524 | { 525 | "cell_type": "markdown", 526 | "metadata": {}, 527 | "source": [ 528 | "The solution is therefor as shown in __Equation 5.4.6__." 529 | ] 530 | }, 531 | { 532 | "cell_type": "markdown", 533 | "metadata": {}, 534 | "source": [ 535 | "$$\n", 536 | "\\begin{equation}\n", 537 | "216x+450y = 18(12x+25y)\n", 538 | "\\end{equation}\n", 539 | "\\tag{Equation 5.4.6}\n", 540 | "$$" 541 | ] 542 | }, 543 | { 544 | "cell_type": "markdown", 545 | "metadata": {}, 546 | "source": [ 547 | "We verify these results using the `factor` method in `sympy`." 548 | ] 549 | }, 550 | { 551 | "cell_type": "code", 552 | "execution_count": 10, 553 | "metadata": {}, 554 | "outputs": [ 555 | { 556 | "data": { 557 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIoAAAAVCAYAAACZt3byAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAF3ElEQVRoBe2Z63EUORCAB9cGYLgIWGdw4AgOZwC+CDhncFf8sv+5IAPOEXCQARABjwxwBmecge/75JFKO6t57cM7UNdVWkmtVqvV6m61dqqbm5tq6uX09HQ+dRl/JvlK+t6rJg5nZ2d/IuKvExdzp+KhoyX9gNunzFcUbF7rPU2/pydEqBd8S/8R7euIjzW4fdovYp/a/lvwHzLcxprwfQq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GBehHxWZDB5ckIN6ae9x3jZr1u2T/zHrq68mxGiWO4I6SNGynuCedeScLufl/q/2ckxbu1aSzIKCC3Qya7PIAnkvygNsW6t3ciRAXr2l9AlA5V8xrvH7alNZgpHBfeYGZBK4KyPplD9ITHRAvpITuqfmmajTfG+y6MpPHNfgLme2MvBpJTjYVI7W6Hed8JeuRAJ9w6LKbgoQxlf80boPB8xtlRd5VIr5k7lTSOoyft7dvnI0GBXqP7bBczKaCpxjMQnMh7beZu1e+Wsh/ExhSdcfbf9hF1IUve0GI/FsA0Dn/ixp7u3Iwm/I2WaimKBCBScJGoQHrwGE+4xahT8HZ+Kah7ptfBR8owyUIrB+HGuVl4ne3SpbQ25CDLN6nPsLfOB7QnHPGpafK4w66Rqif5cwRP4K+bz6fd5HZ9AQPJ+H4JrO7rPZ8zPf/JcSI1Ez8jCUQN2cLHw9TkMTaLAZE+Rn1PFQJyDVOBGQ3Yi1djI7btXh1LXBGF2LiTB4HU3HOdgbzvbOKbX6rpB45wKtsKAe3fTqFdisP0WjoKSPurS9ao225x3cjUCeQzVZQ2EjXgl6o1b9QwKye12np+iON2F080qPcEHDRLh4tdZ6T1++Z3HWROuQQCPb0v8fE5V3ymIZHfy/xUTX3MQEuCs3MedJEX2yOQpCBqgt26/Wa/1pFfn9X/droDYm/0xNL9n/AOBsET2mYPnnAAAAAElFTkSuQmCC", 558 | "text/latex": [ 559 | "$\\displaystyle 18 \\cdot \\left(12 x + 25 y\\right)$" 560 | ], 561 | "text/plain": [ 562 | "18⋅(12⋅x + 25⋅y)" 563 | ] 564 | }, 565 | "execution_count": 10, 566 | "metadata": {}, 567 | "output_type": "execute_result" 568 | } 569 | ], 570 | "source": [ 571 | "# Verify the result\n", 572 | "(216 * x + 450 * y).factor()" 573 | ] 574 | }, 575 | { 576 | "cell_type": "markdown", 577 | "metadata": {}, 578 | "source": [ 579 | "__Homework 5.4.2__ Calculate the GCD of $2345$ and $25$. Hint: Make use of the fact that the GCD of the two numbers will also be the GCD of the smallest number, which is $25$, and the remainder of $2345 \\div 25$, which is $20$." 580 | ] 581 | }, 582 | { 583 | "cell_type": "markdown", 584 | "metadata": {}, 585 | "source": [ 586 | "The common elements across terms may include constants and variable." 587 | ] 588 | }, 589 | { 590 | "cell_type": "markdown", 591 | "metadata": {}, 592 | "source": [ 593 | "__Problem 5.4.4__ Factor out the common constants and variables from the expression in __Equation 5.4.7__." 594 | ] 595 | }, 596 | { 597 | "cell_type": "markdown", 598 | "metadata": {}, 599 | "source": [ 600 | "$$\n", 601 | "\\begin{equation}\n", 602 | "6x^{2} + 9xy\n", 603 | "\\end{equation}\n", 604 | "\\tag{Equation 5.4.7}\n", 605 | "$$" 606 | ] 607 | }, 608 | { 609 | "cell_type": "markdown", 610 | "metadata": {}, 611 | "source": [ 612 | "The solution is as shown in __Equation 5.4.8__." 613 | ] 614 | }, 615 | { 616 | "cell_type": "markdown", 617 | "metadata": {}, 618 | "source": [ 619 | "$$\n", 620 | "\\begin{equation}\n", 621 | "6x^{2} + 9xy = 3x(2x + 3y)\n", 622 | "\\end{equation}\n", 623 | "\\tag{Equation 5.4.8}\n", 624 | "$$" 625 | ] 626 | }, 627 | { 628 | "cell_type": "markdown", 629 | "metadata": {}, 630 | "source": [ 631 | "We confirm the result in `sympy`." 632 | ] 633 | }, 634 | { 635 | "cell_type": "code", 636 | "execution_count": 11, 637 | "metadata": {}, 638 | "outputs": [ 639 | { 640 | "data": { 641 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG0AAAAVCAYAAABMiWD6AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEz0lEQVRoBeWZ7VEcMQyGNwwFHJRwdECggkAHQCoIdBCGX/CPIR0AFWSgA0gFfHQAHeTmOiDvYyzjNd7bu5x3j0w045Mt25JWkiXvXvXy8lItsh0fHw8XKf+jy87ZZ6laIJycnHyX+PUFqvAviB56OwVdPxFpgCaGQgduUFUDYcZnot96WlEkvjtiuCl8GDP2ehhtQ3MjtUPRH+N1H7HvdS9uQ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0tYkIxiixoTBg/L2PXEsOhjl7cOaN30NqGKkfUhRrGuCn6DgmB1yDkWvvgfEaSxul9Ih5z93Xs09jQ5ODg3kf46b9W413NmBSPWPeOTZ85YfSF0hZ3jd4lTBH9CW6VY504iTPfBFpZTxhgXceh6b2AT3eojmCmUOythRP9NgnwtpSQY/q1ERRm2idAA5SIzM5UJ9SQ2Y5faU0/nI63TvwQpwmRUmz2dtgo8o9TUg36mm4incglpNMiTDgixKptbG0aI5Thr2cXq6m2e6eMddeatu797Ce9ehbHCeG908+dVHL+P+wrZZx1wiZaSE1TQo48BG0IzzTi6zt/x+wdy4fNsIrwh/TEnHJ8nQ9igAAAABJRU5ErkJggg==", 642 | "text/latex": [ 643 | "$\\displaystyle 3 x \\left(2 x + 3 y\\right)$" 644 | ], 645 | "text/plain": [ 646 | "3⋅x⋅(2⋅x + 3⋅y)" 647 | ] 648 | }, 649 | "execution_count": 11, 650 | "metadata": {}, 651 | "output_type": "execute_result" 652 | } 653 | ], 654 | "source": [ 655 | "# Verify the result\n", 656 | "(6 * x**2 + 9 * x * y).factor()" 657 | ] 658 | }, 659 | { 660 | "cell_type": "markdown", 661 | "metadata": {}, 662 | "source": [ 663 | "__Homework 5.4.3__ Factor out the common constants and variables from the expression $12x^{3}y+18x^{2}y$." 664 | ] 665 | }, 666 | { 667 | "cell_type": "markdown", 668 | "metadata": {}, 669 | "source": [ 670 | "## 5.5 Factoring quadratic polynomials" 671 | ] 672 | }, 673 | { 674 | "cell_type": "markdown", 675 | "metadata": {}, 676 | "source": [ 677 | "In this section we explore the factoring of quadratic ($2^{\\text{nd}}$-degree) polynomials $a_{2}x^{2} + a_{1} x + a_{0}$, where $a_{2} \\ne 0$." 678 | ] 679 | }, 680 | { 681 | "cell_type": "markdown", 682 | "metadata": {}, 683 | "source": [ 684 | "To factor quadratic expression, we follow a few steps. First, we write the expression in decreasing order of the exponents. As an exmple, we will use the quadratic expression $x^{2}+5x+6$, which is in decreasing order of the powers of the variable $x$." 685 | ] 686 | }, 687 | { 688 | "cell_type": "markdown", 689 | "metadata": {}, 690 | "source": [ 691 | "Next, we write two sets of parentheses as shown in __Equation 5.5.1__." 692 | ] 693 | }, 694 | { 695 | "cell_type": "markdown", 696 | "metadata": {}, 697 | "source": [ 698 | "$$\n", 699 | "\\begin{equation}\n", 700 | "(x \\ \\ \\ )(x \\ \\ \\ )\n", 701 | "\\end{equation}\n", 702 | "\\tag{Equation 5.5.1}\n", 703 | "$$" 704 | ] 705 | }, 706 | { 707 | "cell_type": "markdown", 708 | "metadata": {}, 709 | "source": [ 710 | "Next, we have to consider all the pairs of number that multiply to get $a_{0}=6$. We might try $+3$ and $+2$. These are added to the parentheses as shown in __Equation 5.5.2__." 711 | ] 712 | }, 713 | { 714 | "cell_type": "markdown", 715 | "metadata": {}, 716 | "source": [ 717 | "$$\n", 718 | "\\begin{equation}\n", 719 | "(x + 3)(x + 2)\n", 720 | "\\end{equation}\n", 721 | "\\tag{Equation 5.5.2}\n", 722 | "$$" 723 | ] 724 | }, 725 | { 726 | "cell_type": "markdown", 727 | "metadata": {}, 728 | "source": [ 729 | "Distribution confirms that we have the correct solution as shown in __Equation 5.5.3__." 730 | ] 731 | }, 732 | { 733 | "cell_type": "markdown", 734 | "metadata": {}, 735 | "source": [ 736 | "$$\n", 737 | "\\begin{equation}\n", 738 | "(x + 3)(x + 2) = x^{2} + 2x + 3 x + 6 = x^{2} + 5x + 6\n", 739 | "\\end{equation}\n", 740 | "\\tag{Equation 5.5.3}\n", 741 | "$$" 742 | ] 743 | }, 744 | { 745 | "cell_type": "markdown", 746 | "metadata": {}, 747 | "source": [ 748 | "In this example we had that $a_{2}=1$. This is not always the case." 749 | ] 750 | }, 751 | { 752 | "cell_type": "markdown", 753 | "metadata": {}, 754 | "source": [ 755 | "__Problem 5.5.1__ Factor the quadratic expression in __Equation 5.5.4__." 756 | ] 757 | }, 758 | { 759 | "cell_type": "markdown", 760 | "metadata": {}, 761 | "source": [ 762 | "$$\n", 763 | "\\begin{equation}\n", 764 | "2x^{2} + 7x + 3\n", 765 | "\\end{equation}\n", 766 | "\\tag{Equation 5.5.4}\n", 767 | "$$" 768 | ] 769 | }, 770 | { 771 | "cell_type": "markdown", 772 | "metadata": {}, 773 | "source": [ 774 | "Noe $a_{2}=2$. One pair of numbers that multiply to $2$ is $+2$ and $+1$. We use two pairs of parentheses are before as shown in __Equation 5.5.5__." 775 | ] 776 | }, 777 | { 778 | "cell_type": "markdown", 779 | "metadata": {}, 780 | "source": [ 781 | "$$\n", 782 | "\\begin{equation}\n", 783 | "(2x \\ \\ \\ )(x \\ \\ \\ )\n", 784 | "\\end{equation}\n", 785 | "\\tag{Equation 5.5.5}\n", 786 | "$$" 787 | ] 788 | }, 789 | { 790 | "cell_type": "markdown", 791 | "metadata": {}, 792 | "source": [ 793 | "Now we have to think of pairs of numbers that multiply to $3$, but such that the two terms that will contain $x$ will add to $7$. The only pair of numbers that satisfy this condition is $+1$ and $+3$. We add these to the parentheses as shown in __Equation 5.5.6__, where we also use distribution to confirm our factorization." 794 | ] 795 | }, 796 | { 797 | "cell_type": "markdown", 798 | "metadata": {}, 799 | "source": [ 800 | "$$\n", 801 | "\\begin{equation}\n", 802 | "(2x + 1)(x + 3) = 2x^{2} +6x + 1x +3 = 2x^{2} + 7x + 3\n", 803 | "\\end{equation}\n", 804 | "\\tag{Equation 5.5.6}\n", 805 | "$$" 806 | ] 807 | }, 808 | { 809 | "cell_type": "markdown", 810 | "metadata": {}, 811 | "source": [ 812 | "We use `sympy` to confirm the result." 813 | ] 814 | }, 815 | { 816 | "cell_type": "code", 817 | "execution_count": 12, 818 | "metadata": {}, 819 | "outputs": [ 820 | { 821 | "data": { 822 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIkAAAAVCAYAAABygM3xAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAE5klEQVRoBd2a7VHcMBCGHeYKANLBpYMDKgh0AKSCQAdk+AX/MtABpAIGOjhSAR8dHCUw1wF5HyE5sixb9nFnf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BPWVJiAaLAnus+d7Mi8EHG335O1Q4PbVJbKE3V+73swn3ato3YTY0Z4fvtv+fXo1g4BdlkFYv9dEHiXOt5XzFzIbTlBjeShGV7J/I2s4DCbxMEX5iJkvGM207XVEpK+cIg4eOx6mHy4J85S1FJUBUWmfplIjFpSNDwewy3PW6A+NFHzMKwv1qB2U7Ch17b4DaQ4EaF4ENiRvJdgaAzAcAAjFUAiCX/VfV860GnC5JNZiyD4g8UA1j3+wkxRM9Ggc9VWKA2VsGO+2aEzBHJBfUSs3fXzBi6cTZjKjkHfVZPxjX2DekdN34F1v8QTFRGXf7vg+ztq5ws2qZsDFUmTe2gq9IpFi186wQz/PFxW7NZxreOJjPNqs+FsS3Etoa5dO51wvbU5lvOZ2DhuVtb7QoznPiPm8tiZc6Y7HHtVeB2NozbxrKKWLTBIMTNrSRkDlc6f59HtuxEPLOskKuIRZuxLOCW/2caPejwwsFsX7zVB6421rvSVQz8rsOX2CZX35Jbq4RFKbgaQQy3f3KvnGU18DZTAAAAAElFTkSuQmCC", 823 | "text/latex": [ 824 | "$\\displaystyle \\left(x + 3\\right) \\left(2 x + 1\\right)$" 825 | ], 826 | "text/plain": [ 827 | "(x + 3)⋅(2⋅x + 1)" 828 | ] 829 | }, 830 | "execution_count": 12, 831 | "metadata": {}, 832 | "output_type": "execute_result" 833 | } 834 | ], 835 | "source": [ 836 | "# Verify the result\n", 837 | "(2 * x**2 + 7 * x + 3).factor()" 838 | ] 839 | }, 840 | { 841 | "cell_type": "markdown", 842 | "metadata": {}, 843 | "source": [ 844 | "__Problem 5.5.2__ Factor the quadratic expression in __Equation 5.5.7__." 845 | ] 846 | }, 847 | { 848 | "cell_type": "markdown", 849 | "metadata": {}, 850 | "source": [ 851 | "$$\n", 852 | "\\begin{equation}\n", 853 | "2x^{2} - 5x - 12\n", 854 | "\\end{equation}\n", 855 | "\\tag{Equation 5.5.7}\n", 856 | "$$" 857 | ] 858 | }, 859 | { 860 | "cell_type": "markdown", 861 | "metadata": {}, 862 | "source": [ 863 | "The results are shown in __Equation 5.5.8__, where we also use distribution to confirm the result." 864 | ] 865 | }, 866 | { 867 | "cell_type": "markdown", 868 | "metadata": {}, 869 | "source": [ 870 | "$$\n", 871 | "\\begin{equation}\n", 872 | "(2x + 3)(x - 4) = 2x^{2} - 8x + 3x - 12 = 2x^{2} - 5x - 12\n", 873 | "\\end{equation}\n", 874 | "\\tag{Equation 5.5.8}\n", 875 | "$$" 876 | ] 877 | }, 878 | { 879 | "cell_type": "markdown", 880 | "metadata": {}, 881 | "source": [ 882 | "We also use `sympy` to verify the result." 883 | ] 884 | }, 885 | { 886 | "cell_type": "code", 887 | "execution_count": 13, 888 | "metadata": {}, 889 | "outputs": [ 890 | { 891 | "data": { 892 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIkAAAAVCAYAAABygM3xAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFFElEQVRoBd2a7XEURxCG15QCEIQgMhAoAosM+IgAyMAufkn/XDgDIAIXZCATgYAMIAT5MpCfZ7y9np2dvduT7+RdddWoZ3pmerrf6flaXXN9fd3k6ezs7CgvLzW/Cz92oWNp+NV8vtdkdH5+/gvF40y05OxR68+NfLhjWGyDwQC3n4x0CVCewk7gvybBgv5gs4H9Gv46N5uyQb+Cv8/lm/K0r2KB/Ii+gc9j8leWkX/bpHMO9a39gdEhNunPW+R/5vZR7uGWggShHT7DH+WNl5LH7u/Y+g3+rLQZ2VdkP8NXZV2tTLsqFsgF9B38SfQj/5a8gD4h3wM62syFY59+GRARJA15F8NH0jPyn3JbKXe4xXGjs+/yRkvJ44yTtI70S/+m0hgWyjuAVcbY7ioGn0DvnRjvlPTqhgPZ7xX9DYygCOw3Ich4h1sEyXM6b7UlZ8r+tyw2e8w4SaYqtX7pnytpCo1hcUrn7xU9An2I3J1m36QPU/0obfFIFCdTImzu8iELTp3xkHA7oGBk/YjKhfEX2O+doLfCKz7o33PS2oWwAQuD4Zg2Y8AeVsadjQi7tf9+blDrr6KxUyThdkAD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4M8vNqH9F52zr15yY75F3EYhvse7h1v0xTQ3sOPYWXF79tBphFW3zw/xN+UZzy9B3YfJewGDi3RlDD7W9dFUDZaSyIAQAAAABJRU5ErkJggg==", 893 | "text/latex": [ 894 | "$\\displaystyle \\left(x - 4\\right) \\left(2 x + 3\\right)$" 895 | ], 896 | "text/plain": [ 897 | "(x - 4)⋅(2⋅x + 3)" 898 | ] 899 | }, 900 | "execution_count": 13, 901 | "metadata": {}, 902 | "output_type": "execute_result" 903 | } 904 | ], 905 | "source": [ 906 | "# Verify the result\n", 907 | "(2 * x**2 - 5 * x - 12).factor()" 908 | ] 909 | }, 910 | { 911 | "cell_type": "markdown", 912 | "metadata": {}, 913 | "source": [ 914 | "__Problem 5.5.3__ Factor the quadratic expression in __Equation 5.5.9__." 915 | ] 916 | }, 917 | { 918 | "cell_type": "markdown", 919 | "metadata": {}, 920 | "source": [ 921 | "$$\n", 922 | "\\begin{equation}\n", 923 | "40 x^{2} - 40 x -240\n", 924 | "\\end{equation}\n", 925 | "\\tag{Equation 5.5.9}\n", 926 | "$$" 927 | ] 928 | }, 929 | { 930 | "cell_type": "markdown", 931 | "metadata": {}, 932 | "source": [ 933 | "We note that we can also factor the GCD before factoring. The result is shown in __Equation 5.5.10__, and verified using `sympy`." 934 | ] 935 | }, 936 | { 937 | "cell_type": "markdown", 938 | "metadata": {}, 939 | "source": [ 940 | "$$\n", 941 | "\\begin{equation}\n", 942 | "40 x^{2} - 40 x -240 = 40(x^{2} - x - 6) = 40(x + 2)(x - 3)\n", 943 | "\\end{equation}\n", 944 | "\\tag{Equation 5.5.10}\n", 945 | "$$" 946 | ] 947 | }, 948 | { 949 | "cell_type": "code", 950 | "execution_count": 14, 951 | "metadata": {}, 952 | "outputs": [ 953 | { 954 | "data": { 955 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJkAAAAVCAYAAABVLkwZAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFoUlEQVRoBeWa7VHcMBCGHYYCgHRwdECg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25aG4fFooTYdbwdxIsc63Nt9XOU0rYADLxGHU6R8Ud604Xm4nxmiGZZ2KfOT/3+Jp1rTGjYx3HJIlLSe2JTAEm8mYy5RsHCCiL8IAvz60Qu8zQb53s1nqS0opq7ZRM5LBYlQZDxBT791gHAGASfiOUo5SJnHQUog7IXe/WRCUMwImuS5mHhkCsXTzw3TjWBNE3ig2Khea2MlbMDW5uyPuO6iIXzV1gQqKuqywymtosJ1WmScViQyQiMWnCI/xe+6lKZngk4625UOd4kYxEG1AJU+jHE6fW2sAvTF5Bj9Y17X7Rs6scjqMGAOqZ1/1DDTXw2XAp2PJZ2F7EohAOJh4SUrgWBZ71NOyzIZDli8SklSfklE6jsqLhMoxoZUvpmKWg3OBI3jC4yFwW96KpkAfHou1Npg1IwC9kDoNjJi9KbYZTbcAY/ZnUOC/lKgiAZsOnS+/uWeNYR7LCoBZlXEDIOg1HMN6qghIF8biBguOhT83sdwDXRb3WiKyWyAbuAYCqkh8W7UcERjqtXtcujE5lpkeZlU4FBDCrY1H6ri2zCD/NOFMl0DgvZfqOC7+FbZuTOx5t3zPBth0X2B3JjwNgsLRbfTYZ+oxt74ikpkH8sAhuE/0xppDaw0Jxk4bEv/o2O+c4Yi4VBBnyiDPe5frv8E6ebuiqOV+vOahnSBhYc79YRb9k3Lu8/FqP+B+So4/SfkzfWf0+Oqm9WxuETvg1jz7xgMe1Mxu7gbTW+44y7Y2ZlPD4Nm6XnAoup3slCNPjzmjfU8DIRujpZyw9+1+SXgH6fLmr+zQMW/wBgZ91/AEkWrQAAAABJRU5ErkJggg==", 956 | "text/latex": [ 957 | "$\\displaystyle 40 \\left(x - 3\\right) \\left(x + 2\\right)$" 958 | ], 959 | "text/plain": [ 960 | "40⋅(x - 3)⋅(x + 2)" 961 | ] 962 | }, 963 | "execution_count": 14, 964 | "metadata": {}, 965 | "output_type": "execute_result" 966 | } 967 | ], 968 | "source": [ 969 | "# Verify the result\n", 970 | "(40 * x**2 - 40 * x - 240).factor()" 971 | ] 972 | }, 973 | { 974 | "cell_type": "markdown", 975 | "metadata": {}, 976 | "source": [ 977 | "__Homework 5.5.1__ Factor the quadratic expression $2 x^{2} + 6 x - 20$." 978 | ] 979 | }, 980 | { 981 | "cell_type": "markdown", 982 | "metadata": {}, 983 | "source": [ 984 | "Some of the simplest polynomials to factor are those that can be written as $x^{2} - a^{2}$. These are called __difference of squares__. The results is simply $(x-a)(x+a)$. Note that distribution shows that the terms containing $x$ cancel out." 985 | ] 986 | }, 987 | { 988 | "cell_type": "markdown", 989 | "metadata": {}, 990 | "source": [ 991 | "__Problem 5.5.4__ Factor the difference of squares in __Equation 5.5.11__." 992 | ] 993 | }, 994 | { 995 | "cell_type": "markdown", 996 | "metadata": {}, 997 | "source": [ 998 | "$$\n", 999 | "\\begin{equation}\n", 1000 | "x^{2} - 9\n", 1001 | "\\end{equation}\n", 1002 | "\\tag{Equation 5.5.11}\n", 1003 | "$$" 1004 | ] 1005 | }, 1006 | { 1007 | "cell_type": "markdown", 1008 | "metadata": {}, 1009 | "source": [ 1010 | "The result is shown in __Equation 5.5.12__, and confirmed using `sympy`." 1011 | ] 1012 | }, 1013 | { 1014 | "cell_type": "markdown", 1015 | "metadata": {}, 1016 | "source": [ 1017 | "$$\n", 1018 | "\\begin{equation}\n", 1019 | "x^{2} - 9 = (x^{2} - 3^{2}) = (x - 3)(x + 3)\n", 1020 | "\\end{equation}\n", 1021 | "\\tag{Equation 5.5.12}\n", 1022 | "$$" 1023 | ] 1024 | }, 1025 | { 1026 | "cell_type": "code", 1027 | "execution_count": 15, 1028 | "metadata": {}, 1029 | "outputs": [ 1030 | { 1031 | "data": { 1032 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAH8AAAAVCAYAAABv0jEvAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAD0UlEQVRoBd2Zb1LbMBDF3Q4HgB4hR0jLCRpuAPQEhRukw6fkW4feoPQEHbhB4AT8uQE9ApMbpO/nSu7GyLEtHCfKzmwky7K07612JTvZYrH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SYptvEZvggq0qtF2tg+r/fPhVpBUxY1X4610o3SqftcWyi1zAQZkPH/msMD4kVP0xso4V2MeY4InJaLvIBXwv82Gjwq2MXvYeO+866sIyBk/s2LvEBRyE+PgLBo2N03ubytwAAAAASUVORK5CYII=", 1033 | "text/latex": [ 1034 | "$\\displaystyle \\left(x - 3\\right) \\left(x + 3\\right)$" 1035 | ], 1036 | "text/plain": [ 1037 | "(x - 3)⋅(x + 3)" 1038 | ] 1039 | }, 1040 | "execution_count": 15, 1041 | "metadata": {}, 1042 | "output_type": "execute_result" 1043 | } 1044 | ], 1045 | "source": [ 1046 | "# Verify the result\n", 1047 | "(x**2 - 9).factor()" 1048 | ] 1049 | }, 1050 | { 1051 | "cell_type": "markdown", 1052 | "metadata": {}, 1053 | "source": [ 1054 | "__Homework 5.5.2__ Factor the difference of squares $x^{2} - 100$." 1055 | ] 1056 | }, 1057 | { 1058 | "cell_type": "markdown", 1059 | "metadata": {}, 1060 | "source": [ 1061 | "__Problem 5.5.5__ Factor the difference of squares in __Equation 5.5.13__." 1062 | ] 1063 | }, 1064 | { 1065 | "cell_type": "markdown", 1066 | "metadata": {}, 1067 | "source": [ 1068 | "$$\n", 1069 | "\\begin{equation}\n", 1070 | "25x^{2} - 81y^{2}\n", 1071 | "\\end{equation}\n", 1072 | "\\tag{Equation 5.5.13}\n", 1073 | "$$" 1074 | ] 1075 | }, 1076 | { 1077 | "cell_type": "markdown", 1078 | "metadata": {}, 1079 | "source": [ 1080 | "The result is shown in __Equation 5.5.14__, and confirmed using `sympy`." 1081 | ] 1082 | }, 1083 | { 1084 | "cell_type": "markdown", 1085 | "metadata": {}, 1086 | "source": [ 1087 | "$$\n", 1088 | "\\begin{equation}\n", 1089 | "25x^{2} - 81y^{2} = (5x)^{2} - (9y)^{2} = (5x - 9y)(5x + 9y)\n", 1090 | "\\end{equation}\n", 1091 | "\\tag{Equation 5.5.14}\n", 1092 | "$$" 1093 | ] 1094 | }, 1095 | { 1096 | "cell_type": "code", 1097 | "execution_count": 16, 1098 | "metadata": {}, 1099 | "outputs": [ 1100 | { 1101 | "data": { 1102 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKkAAAAVCAYAAAA93c4hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFO0lEQVRoBe2a61EUQRDHV8oAKI0AzMBHBEoGqBGgGWD5Cb5RkIEagY8M1AgAM8AMVDLA32+ZWWeH2bv14JZjj67qm9meV8+/e3oeUJ2dnVUp7+zsrKfft/mrx+cW4zamqY+VsFmpEtrd3d3m82EiqpC1vi1Dtgqvp/WWKL/O3MVpJgptW5gia33bMbJlxfgCvnf04gDKJukTwHlTC8IP33/IrsI/gsi89Iiy0/PsYv+i57tEw3vkty6jO2110lPS90m/U7PUHyXGzGuu+NZOyiA63nfSRznSyE6QaVjr/IS/wHvIF95Bw7yO0fcd+QPSitSo9R12kTmfmYi29vuUtBcO1BsdxmFOc8f3brDQPmm6GlLD/UCZ56ngBuU/oOs99K8dVL3JO58jss53Q9mMZHtxe92z/UJiDBbP0N8t9r92hTDnQfCNZ9IXMyrZ0z7XVs3ttRQtPbo8Y85Gt5ko4CVufftYVIzVv+8ccqwGwXcFkLsGyhW6Ud+J8/wuKP4ryB4Xyv5H5AJ4Ma3BGDEeEl+3e7e8b5OARqFXlLva7sPe6j2TxosUn+e3URLrSU/gLdi6L2HpkDaeZwchxvJi41iep3NyHpL6VdRzbur+AD7mu9n6QtkH0tKRR9zEr6lPvkSjwxg8BsN3BUSNJl6OukgDfkKpA9ibv6whPcuktB/qeP47hD2vuKVa3z48kw1NLoraEbOBvTxJ6iW9VXfSr3Cup5HS3aZE4lbqP687VowHwVcn1VClLbEGGuNtwKcRdfJucUaQ5qKFzCiUGtf6GjZGGKNZWs7nIGQ0r9CvWVDkddA4n5/h20UlGfFyLCZFQev2cdKxYjwIvm73OlA0GtlepKMaJb0Vmj8KaWzsU5a36Lpf0tJWGevWKXU0pE9Dpn3pOe1ax460oePDa8iM8jqn27wOKbuI1F1HjX0YNffglHTwXBbLbd9H32vHmDkaVJrFGidAqm4V5aVXiokvO7QZBF+dtJNQwu3PJxydrkS1gSiPRo51SsaOZcXUCVPQNU6xTR9h6LdlAGQxquugjluRakDnE6O/Mh1bWdeZfRbno7t/xBiDYMw4LQyiBshdrAab5pkulvVJaSd+rb6RXSm+bvduWRqiRJ6lSmVx9eXOWaFgNHZzSUK2KpcGuCaZzvcNnQQ4ktG+if5B6FyMFhfmGcqdk/hNo2XD+ErxNZK6ZXWdq95jIC8+OWm8OroE5/vMt1uqMleVhrXfSF5MSv3E8rmkjGmU8AK3Rr52SFIdS/3zqC0Gqc58Tn35cLHmbWyX0ygxHgpfI6lRwiejEvnnxOaCZAW+t0PFeM7U4PJvyi5EFmSWxYtJaDpYouPlkc4F9Rq9nHdKLWcLequ723EX6eh5P6W6Y8V4EHzvguhHWMNdIAzlmc0IGR3VyKHRm8hE3ujpOU6DVtTVAb6GNv5dV+dttn7rDEWM67PZfcYzkruApBjxz7/+/RrpfQ/1POVjv2+mUtd51DLn3DqPKSzQKDEeDF//C4r/4TuBH6b/17fsefDYh4+7cKBsHT7pKs/l1oUXDmN02oS3c33n/c2YvfF1u5eMHn0iQl15bD9GT9ioXxN5o65vv3vnkuKvkVfc+tKiYnzKBOS50WXxrZ2UTtyufYbwjLGM5AXLLTmSly0vjcVjSsBJvJrnqtiwKw11Fw5j9PKVo/c8uuY3RX4pfD2TRvIi5NnUv7AsGxkVfQ/2UuhZ1AvjpLOoZ/RZdp5lxfhS+Db/mQ/oFYYxkm6SzvSwax9jJ7DRkb+Qtl4D+s77FuPJSJXw/QsGys8o1rWHjwAAAABJRU5ErkJggg==", 1103 | "text/latex": [ 1104 | "$\\displaystyle \\left(5 x - 9 y\\right) \\left(5 x + 9 y\\right)$" 1105 | ], 1106 | "text/plain": [ 1107 | "(5⋅x - 9⋅y)⋅(5⋅x + 9⋅y)" 1108 | ] 1109 | }, 1110 | "execution_count": 16, 1111 | "metadata": {}, 1112 | "output_type": "execute_result" 1113 | } 1114 | ], 1115 | "source": [ 1116 | "# Verify the result\n", 1117 | "(25 * x**2 - 81 * y**2).factor()" 1118 | ] 1119 | }, 1120 | { 1121 | "cell_type": "markdown", 1122 | "metadata": {}, 1123 | "source": [ 1124 | "__Homework 5.5.3__ Factor the difference of squares $4x^{2} - 9y^{2}$." 1125 | ] 1126 | }, 1127 | { 1128 | "cell_type": "markdown", 1129 | "metadata": {}, 1130 | "source": [ 1131 | "We can also factor perfect cubes, $a^{3} - b^{3}$. The general form for factoring perfect cubes is shown in __Equation 5.5.15__." 1132 | ] 1133 | }, 1134 | { 1135 | "cell_type": "markdown", 1136 | "metadata": {}, 1137 | "source": [ 1138 | "$$\n", 1139 | "\\begin{equation}\n", 1140 | "a^{3} - b^{3} = (a - b)(a^{2} + ab + b^{2})\n", 1141 | "\\end{equation}\n", 1142 | "\\tag{Equation 5.5.15}\n", 1143 | "$$" 1144 | ] 1145 | }, 1146 | { 1147 | "cell_type": "markdown", 1148 | "metadata": {}, 1149 | "source": [ 1150 | "Note that $a^{2} + ab + b^{2}$ cannot be factored." 1151 | ] 1152 | }, 1153 | { 1154 | "cell_type": "markdown", 1155 | "metadata": {}, 1156 | "source": [ 1157 | "__Problem 5.5.6__ Factor the perfect cubes in __Equation 5.5.16__." 1158 | ] 1159 | }, 1160 | { 1161 | "cell_type": "markdown", 1162 | "metadata": {}, 1163 | "source": [ 1164 | "$$\n", 1165 | "\\begin{equation}\n", 1166 | "8x^{3} - 27\n", 1167 | "\\end{equation}\n", 1168 | "\\tag{Equation 5.5.16}\n", 1169 | "$$" 1170 | ] 1171 | }, 1172 | { 1173 | "cell_type": "markdown", 1174 | "metadata": {}, 1175 | "source": [ 1176 | "The result follows __Equation 5.5.15__ and is shown in __Equation 5.5.17__, where $a=2x$ and $b=3$." 1177 | ] 1178 | }, 1179 | { 1180 | "cell_type": "markdown", 1181 | "metadata": {}, 1182 | "source": [ 1183 | "$$\n", 1184 | "\\begin{equation}\n", 1185 | "8x^{3} - 27 = (2x)^{3} - 3^{3} = (2x - 3)(4x^{2} + 6x + 9)\n", 1186 | "\\end{equation}\n", 1187 | "\\tag{Equation 5.5.17}\n", 1188 | "$$" 1189 | ] 1190 | }, 1191 | { 1192 | "cell_type": "markdown", 1193 | "metadata": {}, 1194 | "source": [ 1195 | "We verify the result using `sympy`." 1196 | ] 1197 | }, 1198 | { 1199 | "cell_type": "code", 1200 | "execution_count": 17, 1201 | "metadata": {}, 1202 | "outputs": [ 1203 | { 1204 | "data": { 1205 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM8AAAAaCAYAAAAQcgjDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIVElEQVR4Ae2b63VUOQzHLzkUEJIKCB1AUgGhAx4VAB0sJ9/yjQMdABWw0AFLBYF0AFvBZqeD7P/ntXxsjz3jO887D51j7GvLsiRLsuwJd25vb7s9bI4GLi8vD8Xthef4xNcv1T/aHCm2g9OD7RBjGFLIgF+pnC+Zm3da440vz7TWjcrPJa+50+Sl6w8lBeydp6SVGfqk4Kea9kj1XzNM7zMld9B3mnyidR/2IbLH7aUBAta3fMaY8wjJUoEcd2u/55VZ810qpfr1CpTEGj9WsM5+Ca8B7etvNb+o/iNWSuI8fnAXIxiRO1FMrKSG9hfhFI/2hrm9UMTnR5X4foMz/VbfdS9Ce+ReGkDvmvBaNYHSwV1rqJO041j1e+uj1jcn0Rvfd6qaHJuceyM2y/NvJwKCIw/HcEivaKs8VCElQknNIHzonap+Mm2ScAhMbIDxM23KxHFPz6WLExFXMCheSB9j+Ky+TbGROPAdSYjaAwx4n1S4a3bu5JGQlnaYkzDWqR/D+KDabbjqR/pGIT/VXvbFWMvMB+IRuexyTY3RooBvamN0AfRN0EgiSxic3EBnrQ7HCcXmzA3i1wUBEeKeNZqb4IwE4EOFBwt06nStNrwh66BB/B6q/BKTv1RbUHur77/1jQw5sM9PmcfAgR8lasTe57s7+pMoqYkYC5s1eOWIx1cU8Rw7ip04FxrLAR3kETTHyb9ZY+w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Ps9oAAAAASUVORK5CYII=", 1206 | "text/latex": [ 1207 | "$\\displaystyle \\left(2 x - 3\\right) \\left(4 x^{2} + 6 x + 9\\right)$" 1208 | ], 1209 | "text/plain": [ 1210 | " ⎛ 2 ⎞\n", 1211 | "(2⋅x - 3)⋅⎝4⋅x + 6⋅x + 9⎠" 1212 | ] 1213 | }, 1214 | "execution_count": 17, 1215 | "metadata": {}, 1216 | "output_type": "execute_result" 1217 | } 1218 | ], 1219 | "source": [ 1220 | "# Verify the result\n", 1221 | "(8 * x**3 - 27).factor()" 1222 | ] 1223 | }, 1224 | { 1225 | "cell_type": "markdown", 1226 | "metadata": {}, 1227 | "source": [ 1228 | "__Homework 5.5.4__ Factor the perfect cubes $27x^{3} - 64$." 1229 | ] 1230 | }, 1231 | { 1232 | "cell_type": "markdown", 1233 | "metadata": {}, 1234 | "source": [ 1235 | "We also have the sum of perfect cubes shown in __Equation 5.5.18__." 1236 | ] 1237 | }, 1238 | { 1239 | "cell_type": "markdown", 1240 | "metadata": {}, 1241 | "source": [ 1242 | "$$\n", 1243 | "\\begin{equation}\n", 1244 | "a^{3} + b^{3} = (a + b)(a^{2} - ab + b^{2})\n", 1245 | "\\end{equation}\n", 1246 | "\\tag{Equation 5.5.18}\n", 1247 | "$$" 1248 | ] 1249 | }, 1250 | { 1251 | "cell_type": "markdown", 1252 | "metadata": {}, 1253 | "source": [ 1254 | "__Problem 5.5.7__ Factor the sum of perfect cubes in __Equation 5.5.19__." 1255 | ] 1256 | }, 1257 | { 1258 | "cell_type": "markdown", 1259 | "metadata": {}, 1260 | "source": [ 1261 | "$$\n", 1262 | "\\begin{equation}\n", 1263 | "27x^{3} + 8\n", 1264 | "\\end{equation}\n", 1265 | "\\tag{Equation 5.5.19}\n", 1266 | "$$" 1267 | ] 1268 | }, 1269 | { 1270 | "cell_type": "markdown", 1271 | "metadata": {}, 1272 | "source": [ 1273 | "We see the result in __Equation 5.5.20__, where $a=3x$ and $b=2$." 1274 | ] 1275 | }, 1276 | { 1277 | "cell_type": "markdown", 1278 | "metadata": {}, 1279 | "source": [ 1280 | "$$\n", 1281 | "\\begin{equation}\n", 1282 | "27x^{3} + 8 = (3x)^{3} + 2^{3} = (3x + 2)(9x^{2} - 6x + 4)\n", 1283 | "\\end{equation}\n", 1284 | "\\tag{Equation 5.5.20}\n", 1285 | "$$" 1286 | ] 1287 | }, 1288 | { 1289 | "cell_type": "markdown", 1290 | "metadata": {}, 1291 | "source": [ 1292 | "We verify the result using `sympy`." 1293 | ] 1294 | }, 1295 | { 1296 | "cell_type": "code", 1297 | "execution_count": 18, 1298 | "metadata": {}, 1299 | "outputs": [ 1300 | { 1301 | "data": { 1302 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM8AAAAaCAYAAAAQcgjDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIPElEQVR4Ae2b6ZUUOQyAm3kEAEMEQAYwRLCQAUcEQAbLm3/840EGQAQsZMASAUcGsBHs7GTAfp+xasvVrp7qq7YvvWd8ybIky5JcPVz6+fPn5ADbo4Hnz59fgdvTzPGNXD9m/Hx7pNgNTo92Q4zNkAIDfkK5u2ZuXrLHs1wesNcZ5eua99xr8uj6dU0Bh8tT08oCYyj4PstuU/+5wPJ5lnQv6EsW32DfW/MQOeDOpQEd1sfuiqnLA1KkAl3cne0vKzPrUypF/XQEJbnHlxH2OWyRNcC5/qD5nvr3tlKKy5Mn99GD6bkLxbSVNKD9HpxqaB+wdi4U+HxDab9vvEw/GPs2F6ED8lwaUO8seEqto0xwORoMmnZco34VY9b0jUThUV1o3zC27vSEbZaHzP+zTOmE2jeCb4bG2JSFcotiSqSSBgP46uOE+l5tEePtS3UMzsoe99DW0aV0sbb3mGPwYvrYhneMNTpuT2xyO+vUSxI232bXs3xL8a05SZEHxEg7wsicm+TxeJxaS1ACH2l7aBsN8Khhv5bvXG7T90C/0i8e9vR1GoVnoT8E1NnUhYPeFcp35r5Tx2G8oP8XfflaCjINDdZ3VjsSLUV33sXyQfGDhTaR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VZv60fRfEgSTMVs0TaEAAAAASUVORK5CYII=", 1303 | "text/latex": [ 1304 | "$\\displaystyle \\left(3 x + 2\\right) \\left(9 x^{2} - 6 x + 4\\right)$" 1305 | ], 1306 | "text/plain": [ 1307 | " ⎛ 2 ⎞\n", 1308 | "(3⋅x + 2)⋅⎝9⋅x - 6⋅x + 4⎠" 1309 | ] 1310 | }, 1311 | "execution_count": 18, 1312 | "metadata": {}, 1313 | "output_type": "execute_result" 1314 | } 1315 | ], 1316 | "source": [ 1317 | "# Verify the result\n", 1318 | "(27 * x**3 + 8).factor()" 1319 | ] 1320 | }, 1321 | { 1322 | "cell_type": "markdown", 1323 | "metadata": {}, 1324 | "source": [ 1325 | "__Homework 5.5.5__ Factor the sum of perfect cubes $64x^{3} + 125$." 1326 | ] 1327 | }, 1328 | { 1329 | "cell_type": "markdown", 1330 | "metadata": {}, 1331 | "source": [ 1332 | "## 5.6 Factoring rational expressions" 1333 | ] 1334 | }, 1335 | { 1336 | "cell_type": "markdown", 1337 | "metadata": {}, 1338 | "source": [ 1339 | "Polynomials can appear in the numerrator and denominator of a rational expression. In this case, we can factor the numerator and denominator separately. Once this is done, we can cancel out common factors." 1340 | ] 1341 | }, 1342 | { 1343 | "cell_type": "markdown", 1344 | "metadata": {}, 1345 | "source": [ 1346 | "__Problem 5.6.1__ Factor the rational expression in __Equation 5.6.1__." 1347 | ] 1348 | }, 1349 | { 1350 | "cell_type": "markdown", 1351 | "metadata": {}, 1352 | "source": [ 1353 | "$$\n", 1354 | "\\begin{equation}\n", 1355 | "\\frac{2x^{2} + 7x + 6}{x^{2} - 4}\n", 1356 | "\\end{equation}\n", 1357 | "\\tag{Equation 5.6.1}\n", 1358 | "$$" 1359 | ] 1360 | }, 1361 | { 1362 | "cell_type": "markdown", 1363 | "metadata": {}, 1364 | "source": [ 1365 | "We see the solution in __Equation 5.6.2__." 1366 | ] 1367 | }, 1368 | { 1369 | "cell_type": "markdown", 1370 | "metadata": {}, 1371 | "source": [ 1372 | "$$\n", 1373 | "\\begin{equation}\n", 1374 | "\\frac{2x^{2} + 7x + 6}{x^{2} - 4} = \\frac{(2x + 3)(x + 2)}{(x + 2)(x - 2)} = \\frac{2x + 3}{x - 2}\n", 1375 | "\\end{equation}\n", 1376 | "\\tag{Equation 5.6.2}\n", 1377 | "$$" 1378 | ] 1379 | }, 1380 | { 1381 | "cell_type": "markdown", 1382 | "metadata": {}, 1383 | "source": [ 1384 | "In __Equation 5.6.2__, we see that the factor $(x+2)$ is common in the numerator and in the denominator and cancels out. We verify the result using `sympy`." 1385 | ] 1386 | }, 1387 | { 1388 | "cell_type": "code", 1389 | "execution_count": 19, 1390 | "metadata": {}, 1391 | "outputs": [ 1392 | { 1393 | "data": { 1394 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHMAAAAuCAYAAAAbUybPAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGKUlEQVR4Ae2c63HUOhTHnQwFBErYdAChApYO4FIBoYPL5FPyjYEOgAoupANCBQnpgHRwQzoI/5/Q0Wgd7cu2ZDv4zCiSj17nLXktZef29rbKBScnJ3sa+8iPP/P5a+Fvcs35N4/7IDPz76W4NzaHyh9V/qG0b7gp704Cu90NlRzpUAqcRzXvVZ4J9zjCTcWOJJDbM/HKi45obTWMDIgwj2F9UflehvkdWzM9s2+9xA6UXyu9Ff7S41pnGgvPfKG8eJjVnC8099cVTNyozcMV9YOp8nKM6flPuEvnmSpgtR+VP7cWvsMPcEpnhm+aawxCKwJ90nSMlv2eqj98XCXGwWPNkBPVw0BJhugJg8TJnE6U80zatzCLx4SNisqVGtHhUEUatrJYjQMRzPFE5VYhTv0RPOvuJ+VbgfoEY7WOwkFbpfzUcLlyzdGYdk8TusALY+fijcEZqCmTSX6q0UOlWNh0IiwivJRFq3o10FctMAwnSP9cKW80nsaCeNK2cL6kAzvul0vqukY3pR15EdWIbs9iooQPBmrKRGmPVRErMu7TRHgQgCJ5HUGZtoMlAhQPaZr/jucJR7R4pzQGQG6s68t0VD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6fteg2zEgKvG3buaN29lcorsssbZa2EKXoIr3Yep9VYXXTu2zN53fhAEjMcsOLeylzPHPdE0fFJNDwSwXFykJ0joZZ210rFQfNDT/2oaXE64gl780wJA48MykIwSqyD7tigcnaGcT0nAFEweQCNkzw9HhrkK3A6sX7GON9sG4zcmzJF21Z3OiS4RjfK1A8D+K5Evim8VL+lu2TVYYiDCa/GVG/KTAgry70VzYPHd7br1XiEVw6Lxyf5TZ695r0pM+ZagpkjIKVwiFo450nKUcaQAGVyjYMfCWJgDecXKfC8/xYPwb0oU4yiKJge3b0V0c6pd9ICCP9LCK4PhEtXCw0KPOwWmCM1BZ5IGvu9lZg3DNRFkxhZstzLSQPvmexUf8Ksnnk9YSfLndAx3VuBdjZChF6ME2Cp4N8CtLk/6gba9s9v4Zhzu+hwBxYAAAAASUVORK5CYII=", 1395 | "text/latex": [ 1396 | "$\\displaystyle \\frac{2 x^{2} + 7 x + 6}{x^{2} - 4}$" 1397 | ], 1398 | "text/plain": [ 1399 | " 2 \n", 1400 | "2⋅x + 7⋅x + 6\n", 1401 | "──────────────\n", 1402 | " 2 \n", 1403 | " x - 4 " 1404 | ] 1405 | }, 1406 | "execution_count": 19, 1407 | "metadata": {}, 1408 | "output_type": "execute_result" 1409 | } 1410 | ], 1411 | "source": [ 1412 | "# Print the problem using sympy\n", 1413 | "(2 * x**2 + 7 * x + 6) / (x**2 - 4)" 1414 | ] 1415 | }, 1416 | { 1417 | "cell_type": "code", 1418 | "execution_count": 20, 1419 | "metadata": {}, 1420 | "outputs": [ 1421 | { 1422 | "data": { 1423 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAADoAAAArCAYAAAApMZsWAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAD7UlEQVRoBe2a7VEbMRCGz0wKAEpwOiDQAXQQkgoCHZDhF/zLQAeQEqADSAV8dAAlgDsgzyOfbuSzzxwef8iDd0aWtFpJ+2q1Erei8/b2Vkinp6ddst+hUhTb5C/W4T+WvKyzUv/DUsl1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UVv5WcuhywHpqs08bXw0rCor5rGuZapoPLxFPSoVzG3Au9WDmAAat64gaHfvZ/eohG5jH8QEVqdGoAhqQVNWj0qA9HTVAI0PYrQN0TiguT4qtXkQGwL6H8zHMnTXP6wQAAAAAElFTkSuQmCC", 1424 | "text/latex": [ 1425 | "$\\displaystyle \\frac{2 x + 3}{x - 2}$" 1426 | ], 1427 | "text/plain": [ 1428 | "2⋅x + 3\n", 1429 | "───────\n", 1430 | " x - 2 " 1431 | ] 1432 | }, 1433 | "execution_count": 20, 1434 | "metadata": {}, 1435 | "output_type": "execute_result" 1436 | } 1437 | ], 1438 | "source": [ 1439 | "# Verify the result\n", 1440 | "((2 * x**2 + 7 * x + 6) / (x**2 - 4)).factor()" 1441 | ] 1442 | }, 1443 | { 1444 | "cell_type": "markdown", 1445 | "metadata": {}, 1446 | "source": [ 1447 | "__Homework 5.6.1__ Factor the rational expression in __Equation 5.6.3__." 1448 | ] 1449 | }, 1450 | { 1451 | "cell_type": "markdown", 1452 | "metadata": {}, 1453 | "source": [ 1454 | "$$\n", 1455 | "\\frac{2x^{2} + 5x + 3}{x^{2} - 1}\n", 1456 | "\\tag{Equation 5.6.3}\n", 1457 | "$$" 1458 | ] 1459 | }, 1460 | { 1461 | "cell_type": "markdown", 1462 | "metadata": {}, 1463 | "source": [ 1464 | "In chapters 7 and 8 we will learn more about factoring." 1465 | ] 1466 | }, 1467 | { 1468 | "cell_type": "markdown", 1469 | "metadata": {}, 1470 | "source": [] 1471 | } 1472 | ], 1473 | "metadata": { 1474 | "kernelspec": { 1475 | "display_name": "mathematics", 1476 | "language": "python", 1477 | "name": "python3" 1478 | }, 1479 | "language_info": { 1480 | "codemirror_mode": { 1481 | "name": "ipython", 1482 | "version": 3 1483 | }, 1484 | "file_extension": ".py", 1485 | "mimetype": "text/x-python", 1486 | "name": "python", 1487 | "nbconvert_exporter": "python", 1488 | "pygments_lexer": "ipython3", 1489 | "version": "3.10.9" 1490 | }, 1491 | "orig_nbformat": 4 1492 | }, 1493 | "nbformat": 4, 1494 | "nbformat_minor": 2 1495 | } 1496 | --------------------------------------------------------------------------------