(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 17267, 562]*) (*NotebookOutlinePosition[ 17948, 585]*) (* CellTagsIndexPosition[ 17904, 581]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Solving Equations, Inequalities, and Logical Equations", "Title"], Cell[CellGroupData[{ Cell["Solving single equations", "Section"], Cell[TextData[{ "The most commonly used command for solving equations is the ", StyleBox["Solve", FontFamily->"Courier"], " command. You can solve a single equation for one variable with ", StyleBox["Solve[", FontFamily->"Courier"], StyleBox["equation", FontFamily->"Courier", FontSlant->"Italic"], StyleBox[", ", FontFamily->"Courier"], StyleBox["variable", FontFamily->"Courier", FontSlant->"Italic"], StyleBox["]", FontFamily->"Courier"], ". You must use two equal signs in the equation, such as ", Cell[BoxData[ \(TraditionalForm\`x\^2 + x \[Equal] 2\)]], ", to distinguish it from an assignment, such as ", StyleBox["x", FontSlant->"Italic"], " = 5 which assigns the value 5 to the variable ", StyleBox["x", FontSlant->"Italic"], ". Here is an example of ", StyleBox["Solve", FontFamily->"Courier"], ". ", StyleBox["Mathematica", FontSlant->"Italic"], "'s ", StyleBox["Log", FontFamily->"Courier"], " function represents the natural logarithm." }], "Text"], Cell[BoxData[{ \(Clear[a, \ b, \ x]\), "\[IndentingNewLine]", \(Solve[Log[a\ x - 1] \[Equal] b, x]\)}], "Input"], Cell["\<\ That equation had one solution. The next one has several \ solutions.\ \>", "Text"], Cell[BoxData[{ \(Clear[a, \ b, \ c, \ t]\), "\[IndentingNewLine]", \(Solve[a\ t\^4 + b\ t\^2 + c \[Equal] 2, t]\)}], "Input"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " displays the results as a list of solutions. Each solution is a list of \ replacement rules for the variables. In this case, we are only solving for \ one variable, so each inner list only contains one replacement rule. These \ replacement rules can then be used in subsequent calculations. For example, \ suppose that you wanted to list the square of each of the solutions above. \ The first line of output will be a list of the solutions presented as \ replacement rules, and the second line of output will be a list of the \ squares of those solutions. ", StyleBox["Mathematica", FontSlant->"Italic"], "'s ", StyleBox["ReplaceAll", FontFamily->"Courier"], " operator, represented by /., means to make the replacements indicated on \ the right side to the expression on the left side." }], "Text"], Cell[BoxData[{ \(Clear[a, b, c, t]\), "\[IndentingNewLine]", \(solutions = Solve[a\ t\^4 + b\ t\^2 + c \[Equal] 2, t]\), "\[IndentingNewLine]", \(t\^2 /. solutions\)}], "Input"], Cell["We can also check our solutions.", "Text"], Cell[BoxData[{ \(Clear[a, b, c, t]\), "\[IndentingNewLine]", \(Simplify[\((a\ t\^4 + b\ t\^2 + c \[Equal] 2)\) /. solutions]\)}], "Input"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(Solve[\[ExponentialE]\^\(3 x\) \[Equal] \[ExponentialE]\^\(4 x\) + 2, x]\)}], "Input"], Cell[TextData[{ "Sometimes you can get strange results from ", StyleBox["Solve", FontFamily->"Courier"], "." }], "Text"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(Solve[\[ExponentialE]\^\(3 x\) \[Equal] \[ExponentialE]\^\(5 x\) + 2, x]\)}], "Input"], Cell[TextData[{ "The solution of this equation requires solving a fifth degree polynomial. \ If you make the substitution ", StyleBox["u", FontSlant->"Italic"], " = ", Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^x\)]], ", you will see why. There are not explicit formulas for solving fifth \ degree polynomials, so ", StyleBox["Mathematica", FontSlant->"Italic"], " only partially solved this equation. The expression ", Cell[BoxData[ \(Root[2 - #1\^3 + #1\^5 &, 1]\)]], " stands for the first root of the function 2 - ", Cell[BoxData[ \(TraditionalForm\`x\^3 + x\^5\)]], ". The first replacement rule in the solution says that if you find the \ first root of this polynomial, let's call it ", Cell[BoxData[ \(TraditionalForm\`\(\(r\_1\)\(,\)\)\)]], " then a solution to the original problem is \[ImaginaryI] \[Pi] + Log[", Cell[BoxData[ \(TraditionalForm\`r\_1\)]], "]. This is a complex number, with \[ImaginaryI] = ", Cell[BoxData[ \(TraditionalForm\`\@\(-1\)\)]], ". If you change ", Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(5 x\)\)]], " to ", Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(4 x\)\)]], " in the equation above, then the solution will require solving a fourth \ degree polynomial. This does have an explicit formula, so ", StyleBox["Mathematica", FontSlant->"Italic"], " will give the exact solution." }], "Text"], Cell[TextData[{ "Although ", StyleBox["Mathematica", FontSlant->"Italic"], " cannot find the exact solution to ", Cell[BoxData[ \(\[ExponentialE]\^\(3 x\) \[Equal] \[ExponentialE]\^\(5 x\) + 2\)]], ", you can ask for an approximate solution, using ", StyleBox["NSolve", FontFamily->"Courier"], " or ", StyleBox["FindRoot", FontFamily->"Courier"], ". ", StyleBox["NSolve", FontFamily->"Courier"], " has the same syntax as ", StyleBox["Solve", FontFamily->"Courier"], "." }], "Text"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(NSolve[\[ExponentialE]\^\(3 x\) \[Equal] \[ExponentialE]\^\(5 x\) + 2, x]\)}], "Input"], Cell["That's better!", "Text"], Cell[TextData[{ StyleBox["Exercise 2.1:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Use the second derivative test to find the relative maxima and mimima of \ ", StyleBox["f", FontSlant->"Italic"], "(", StyleBox["x", FontSlant->"Italic"], ") = 3", Cell[BoxData[ \(TraditionalForm\`x\^5 - 4 x\^3 + 2 x - 1\)]], ". Try to do this as elegantly and consicely as possible, using the \ techniques above." }], "Text", Background->GrayLevel[0.750011]], Cell[TextData[{ "Sometimes, ", StyleBox["Solve", FontFamily->"Courier"], " does not give you all of the solutions. For example, it ignores special \ cases that may arise for specific values of parameters. It only give general \ solutions. We get the familiar quadratic formula when we ask for a solution \ of the quadratic equation." }], "Text"], Cell[BoxData[{ \(Clear[a, b, c, x]\), "\[IndentingNewLine]", \(Solve[a\ x\^2 + b\ x + c \[Equal] 0, x]\)}], "Input"], Cell["\<\ However, there is a specific value for one of the parameters, a, b, \ or c, that gives a different solution. What is that specific solution? \ Hint: Look to see which values of the parameters are not allowed in the \ general solution.\ \>", "Text"], Cell[TextData[{ StyleBox["Reduce", FontFamily->"Courier"], " gives you a more complete solution. It presents the solution as an \ equivalent logical expression. The symbols ", StyleBox["||", FontFamily->"Courier"], " means \"or\", ", StyleBox["&&", FontFamily->"Courier"], " means \"and\". This notation is borrowed from most computer programming \ languages." }], "Text"], Cell[BoxData[{ \(Clear[a, b, c, x]\), "\[IndentingNewLine]", \(Reduce[a\ x\^2 + b\ x + c \[Equal] 0, x]\)}], "Input"], Cell[TextData[{ "Solve can also miss some solutions because it uses the standard inverse \ functions, which are based on restricted domains. For example, ", StyleBox["ArcSin", FontFamily->"Courier"], " is the inverse of the ", StyleBox["Sin", FontFamily->"Courier"], " function with restricted domain ", Cell[BoxData[ \(TraditionalForm\`\(-\(\[Pi]\/2\)\) \[LessEqual] \[Theta] \[LessEqual] \ \[Pi]\/2\)]], ". So, when Solve uses ", StyleBox["ArcSin", FontFamily->"Courier"], " to solve the following equation, it only gives one solution instead of an \ infinite number of them." }], "Text"], Cell[BoxData[{ \(Clear[\[Theta]]\), "\[IndentingNewLine]", \(Solve[2 Sin[2 \[Theta] + 1] == 1\/2, \[Theta]]\)}], "Input"], Cell[TextData[{ "At least ", StyleBox["Mathematica", FontSlant->"Italic"], " was kind enough to give us a warning that it may have missed some \ solutions. Try using ", StyleBox["Reduce", FontFamily->"Courier"], " instead and see what happens. You can use ", StyleBox["N[ ]", FontFamily->"Courier"], ", too, if you prefer to get decimal approximations instead of complicated \ exact expressions." }], "Text"], Cell["\<\ If you want to restrict the solution set, then you have to use \ Reduce. For example, here are all of the solutions to a cubic \ equation.\ \>", "Text"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(Solve[2 x\^3 - x\^2 - x \[Equal] 0, x]\)}], "Input"], Cell["and here are the integer solutions.", "Text"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(Reduce[2 x\^3 - x\^2 - x \[Equal] 0\ , x, Integers]\)}], "Input"], Cell["and here are the solutions between -1 and 0.", "Text"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(Reduce[2 x^2 - x - 1 \[Equal] 0\ && \(-1\) \[LessEqual] x && x < 0, x]\)}], "Input"], Cell["\<\ You can also restrict solutions to Rationals, Algebraics, Reals, \ Complexes, Primes, and Booleans.\ \>", "Text"], Cell["\<\ You can use Reduce along with Exists and ForAll (these are called \ logical quantifiers) to answer questions about the existence of solutions and \ a variety of other questions. For example, we can check to see the \ conditions on the coefficients, a, b, and c, for which a quadratic equation \ has a root equal to 3.\ \>", "Text"], Cell[BoxData[{ \(Clear[a, b, c, x]\), "\[IndentingNewLine]", \(Reduce[ Exists[x, a\ x\^2 + b\ x + c \[Equal] 0\ && \ x\ \[Equal] \ 3], {a, b, c}]\)}], "Input"], Cell[TextData[{ StyleBox["Exercise 2.2:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " For what values of the line's slope will a line through the origin \ intersect the circle of radius 2 centered at (3, 5)?" }], "Text", Background->GrayLevel[0.750011]], Cell[TextData[{ "If ", StyleBox["NSolve", FontFamily->"Courier"], " fails to solve your equations, then you can resort to ", StyleBox["FindRoot", FontFamily->"Courier"], ". Unlike ", StyleBox["Solve", FontFamily->"Courier"], " and ", StyleBox["Reduce", FontFamily->"Courier"], ", though, ", StyleBox["FindRoot", FontFamily->"Courier"], " can only find numerical solutions. Your equations cannot include any \ arbitrary parameters. ", StyleBox["FindRoot", FontFamily->"Courier"], " requires that you provide one or two intial guesses and it will use them \ to find one solution. If you provide one initial guess, ", StyleBox["FindRoot", FontFamily->"Courier"], " uses Newton's method. If you provide two initial guesses, ", StyleBox["FindRoot", FontFamily->"Courier"], " approximates the derivative in Newton's method. If your function \ involves only real coefficients and you want to find a complex root, you must \ start with a complex initial value. The first arguemnt in ", StyleBox["FindRoot", FontFamily->"Courier"], " is the equation and the second arguement is a list containing the \ variable and the initial guess(es). The example below finds a root of the \ equation sin(", Cell[BoxData[ \(TraditionalForm\`x\^2 + 1\)]], ") = ", Cell[BoxData[ \(TraditionalForm\`1\/3\)]], "with initial guess ", StyleBox["x", FontSlant->"Italic"], " = 1." }], "Text"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(FindRoot[Sin[x\^2 + 1] \[Equal] 1\/3, {x, 1}]\)}], "Input"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " has a collection of commands that you can use to perform algebraic \ transformations of expressions. Sometimes you have to resort to using these \ to get an equation into a form that ", StyleBox["Solve", FontFamily->"Courier"], " can handle. Fortunately, this rarely happens. But you should take a \ quick look at these commands in ", StyleBox["Mathematica", FontSlant->"Italic"], "'s Help Browser, just so you know what is available. Look at ", StyleBox["Simplify", FontFamily->"Courier"], ", ", StyleBox["Expand", FontFamily->"Courier"], ", ", StyleBox["ExpandNumerator", FontFamily->"Courier"], ", ", StyleBox["ExpandDenominator", FontFamily->"Courier"], ", ", StyleBox["RootReduce", FontFamily->"Courier"], ", ", StyleBox["ToRadicals", FontFamily->"Courier"], ", ", StyleBox["TrigExpand", FontFamily->"Courier"], ", ", StyleBox["TrigFactor", FontFamily->"Courier"], ", ", StyleBox["TrigReduce", FontFamily->"Courier"], ", ", StyleBox["TrigToExp", FontFamily->"Courier"], ", and ", StyleBox["ExpToTrig", FontFamily->"Courier"], ". " }], "Text"], Cell[TextData[{ StyleBox["Exercise 2.3:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Suppose that a sphere of radius 10 cm and density 0.2 g/", Cell[BoxData[ \(TraditionalForm\`cm\^3\)]], "is dropped into water with density 1.0 g/", Cell[BoxData[ \(TraditionalForm\`cm\^3\)]], ". The sphere will sink to the depth at which the mass of the displaced \ water equals the mass of the entire sphere. To what depth will the sphere \ sink?" }], "Text", Background->GrayLevel[0.750011]] }, Closed]], Cell[CellGroupData[{ Cell["Solving systems of equations", "Section"], Cell[TextData[{ "You can solve systems of equations using ", StyleBox["Solve", FontFamily->"Courier"], " or ", StyleBox["NSolve", FontFamily->"Courier"], ". Both of these commands have two arguments. The first argument is the \ equation or list of equations and the second argument is the variable or \ variables to be solved for. Lists are enclosed in braces, { }. Here is an \ example in which we solve a list of two equaitons for a list of two \ variables. Geometrically, we are checking to see if a line intersects a \ quartic function." }], "Text"], Cell[BoxData[{ \(Clear[x, y]\), "\[IndentingNewLine]", \(Solve[{2 x + y \[Equal] 1, y == x\^4 - 3 x\^3 + x - 1}, {x, y}]\)}], "Input"], Cell["At how many points do the curves intersect?", "Text"], Cell[TextData[{ StyleBox["Exercise 2.4:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Where does ", StyleBox["y", FontSlant->"Italic"], " = ", Cell[BoxData[ \(TraditionalForm\`x\^4\)]], " intersect the circle of radius 3 centered at (0, 5)?" }], "Text", Background->GrayLevel[0.750011]] }, Closed]], Cell[CellGroupData[{ Cell["Solving inequalities", "Section"], Cell["You can use Reduce to solve inequalities, too.", "Text"], Cell[BoxData[{ \(Clear[x]\), "\[IndentingNewLine]", \(Reduce[1 < Tan[x] < \@3\ && \ x \[Element] Reals, x]\)}], "Input"], Cell[TextData[{ StyleBox["Exercise 2.5:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Find the ordered pairs of integers above the parabola ", StyleBox["y", FontSlant->"Italic"], " = ", Cell[BoxData[ \(TraditionalForm\`x\^2\)]], "and below the line ", StyleBox["y", FontSlant->"Italic"], " = 4." }], "Text", Background->GrayLevel[0.750011]] }, Closed]] }, Open ]] }, FrontEndVersion->"5.2 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 951}}, WindowSize->{939, 671}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, StyleDefinitions -> "PastelColor.nb" ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 71, 0, 184, "Title"], Cell[CellGroupData[{ Cell[1872, 57, 43, 0, 51, "Section"], Cell[1918, 59, 1065, 36, 72, "Text"], Cell[2986, 97, 121, 2, 58, "Input"], Cell[3110, 101, 94, 3, 29, "Text"], Cell[3207, 106, 134, 2, 59, "Input"], Cell[3344, 110, 893, 18, 92, "Text"], Cell[4240, 130, 198, 4, 79, "Input"], Cell[4441, 136, 48, 0, 29, "Text"], Cell[4492, 138, 156, 3, 59, "Input"], Cell[4651, 143, 158, 3, 59, "Input"], Cell[4812, 148, 130, 5, 29, "Text"], Cell[4945, 155, 158, 3, 59, "Input"], Cell[5106, 160, 1469, 39, 92, "Text"], Cell[6578, 201, 536, 20, 29, "Text"], Cell[7117, 223, 163, 3, 59, "Input"], Cell[7283, 228, 30, 0, 29, "Text"], Cell[7316, 230, 511, 17, 35, "Text"], Cell[7830, 249, 358, 8, 50, "Text"], Cell[8191, 259, 125, 2, 59, "Input"], Cell[8319, 263, 261, 5, 50, "Text"], Cell[8583, 270, 399, 12, 50, "Text"], Cell[8985, 284, 126, 2, 59, "Input"], Cell[9114, 288, 628, 17, 52, "Text"], Cell[9745, 307, 132, 2, 71, "Input"], Cell[9880, 311, 436, 13, 50, "Text"], Cell[10319, 326, 163, 4, 29, "Text"], Cell[10485, 332, 116, 2, 59, "Input"], Cell[10604, 336, 51, 0, 29, "Text"], Cell[10658, 338, 129, 2, 59, "Input"], Cell[10790, 342, 60, 0, 29, "Text"], Cell[10853, 344, 156, 3, 58, "Input"], Cell[11012, 349, 123, 3, 29, "Text"], Cell[11138, 354, 343, 6, 50, "Text"], Cell[11484, 362, 185, 4, 59, "Input"], Cell[11672, 368, 290, 7, 35, "Text"], Cell[11965, 377, 1471, 44, 115, "Text"], Cell[13439, 423, 122, 2, 71, "Input"], Cell[13564, 427, 1228, 46, 71, "Text"], Cell[14795, 475, 538, 14, 56, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[15370, 494, 47, 0, 35, "Section"], Cell[15420, 496, 576, 13, 71, "Text"], Cell[15999, 511, 154, 3, 59, "Input"], Cell[16156, 516, 59, 0, 29, "Text"], Cell[16218, 518, 341, 12, 35, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[16596, 535, 39, 0, 35, "Section"], Cell[16638, 537, 62, 0, 29, "Text"], Cell[16703, 539, 130, 2, 61, "Input"], Cell[16836, 543, 403, 15, 35, "Text"] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)