Lecture 15: Linear Combinations: Marvin and Marilyn Get Their Meals, Bees, Chemical Reaction Systems, and Consistency Winfried Just Department of Mathematics, Ohio University September 28, 2015 Winfried Just, Ohio University MATH3200, Lecture 15: Linear Combinations A health-conscious couple Marilyn and Marvin decide to go on Dr. Losit’s new scientifically proven diet. According to this expert, they should eat exactly 50 grams of sugar, exactly 300 grams of protein, and exactly 100 grams of fat per day, and restrict themselves to one meal per day prepared from a mixture of a wide range of products offered by his company. Being on a budget and having somewhat different tastes, they decide to purchase Losit-Quick (strawberry taste, which they both like), Losit-Fast (Marylin’s beloved watermelon taste that Marvin cannot stand), and Losit-Easy (beer-flavored for Marvin, detested by Marylin). Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations The products are in, now what? After receiving the products in the mail and reading the fine print on the labels, they discover that: One serving of Losit-Quick contains 20 grams of sugar, 200 grams of protein, and 20 grams of fat. One serving of Losit-Fast contains 15 grams of sugar, 50 grams of protein, and 40 grams of fat. One serving of Losit-Easy contains 25 grams of sugar, 150 grams of protein, and 60 grams of fat. How should they compose their meals if they want to strictly follow the guidelines? Each of our protagonists sits down with a pencil and paper and tries to figure it out. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marilyn’s reasoning Marilyn reasons as follows: I will need x1 servings of Losit-Quick and x2 servings of Losit-Fast. The numbers x1 , x2 need to be chosen in such a way that the total amounts of sugar, protein, and fat add up to exactly the recommended values. They must be solutions of the following system of linear equations, where all quantities are expressed in grams: 20x1 + 15x2 = 50 200x1 + 50x2 = 300 20x1 + 40x2 = 100 (the total amount of sugar) (the total amount of protein) (the total amount of fat) She is really good at Gaussian elimination and uses it to quickly solve the system. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marilyn’s solution 20 15 50 subtract 10(row 1) from row 2 20 15 50 200 50 300 0 −100 −200 −→ 20 40 100 20 40 100 20 15 50 20 15 50 1 from row 3 0 −100 −200 subtract row 0 −100 −200 −→ 20 40 100 0 25 50 20 15 0 −100 0 25 50 1 divide row 1 by 20 −200 0 −→ 50 0 Ohio University – Since 1804 Winfried Just, Ohio University 0.75 −100 25 2.5 −200 50 Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marilyn’s solution, continued 1 0.75 2.5 1 0.75 2.5 2 by -100 0 −100 −200 divide row 0 1 2 −→ 0 25 50 0 25 50 1 0.75 2.5 1 0.75 2.5 divide row 3 by 25 0 1 2 0 1 2 −→ 0 25 50 0 1 2 1 0.75 2.5 1 0.75 2.5 subtract row 2 from row 3 0 1 2 0 1 2 −→ 0 1 2 0 0 0 Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marilyn’s starts cooking Marilyn has found the augmented matrix 1 0.75 2.5 ~ 1 2 Ab = 0 0 0 0 of the equivalent system x1 + 0.75x2 = 2.5 x2 = 2 0=0 This tells her that she needs to mix x2 = 2 servings of Losit-Fast with x1 = 1 serving of Losit-Quick. She starts preparing her meal. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations In the meantime Marvin ... who isn’t a big fan of Gaussian elimination tried randomly guessing an appropriate mixture of Losit-Fast and Losit-Easy, without much success. He likes vector notation though, and reasons as follows: Let ~vQ ,~vE ,~vM be the vectors of amounts of sugar, protein, and fat in one serving of Losit-Quick, Losit-Easy, and in the meal that I need to compose. Then 20 ~vQ = 200 20 25 ~vE = 150 60 ~vM 50 = 300 100 I need to find scalars dQ , dE such that ~vM is the linear combination dQ ~vQ + dE ~vE = ~vM , where dQ , dE are the numbers of servings of Losit-Quick and Losit-Easy that I need for my meal. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin is getting hungry It remains to find the actual numbers dQ , dE such that ~vM is the linear combination dQ ~vQ + dE ~vE = ~vM . Hmmm. ???? Eventually hunger prevails over pride and Marvin decides that his notation and the phrase linear combination look sufficiently impressive so that it wouldn’t be too embarassing to ask: “Hey, sweethart, I have practically figured it out. Could you just give me a hand with these boring calculations?” Marilyn tells him: “Sorry, bud. You will need to add some of my Losit-Fast.” Homework 29: Is Marilyn right or just being nasty? Homework 30: If Marilyn is right, what is the minimum amount of Losit-Fast that Marvin will need to digest? What is the maximum amount of Losit-Easy that he can add? Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Solution for Homework 29 Marilyn argues as follows: You will need x1 servings of Losit-Quick and x2 servings of Losit-Easy. The numbers x1 , x2 need to be chosen in such a way that the total amounts of sugar, protein, and fat add up to exactly the recommended values. They must be solutions of the following system of linear equations, where all quantities are expressed in grams: 20x1 + 25x2 = 50 200x1 + 150x2 = 300 20x1 + 60x2 = 100 (the total amount of sugar) (the total amount of protein) (the total amount of fat) She now does a Gaussian elimination for this system: Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Gaussian elimination for Homework 29 20 200 20 25 150 60 50 subtract 10(row 1) from row 2 20 0 300 −→ 100 20 25 −100 60 50 −200 100 20 25 50 20 25 50 1 from row 3 0 −100 −200 subtract row 0 −100 −200 −→ 20 60 100 0 35 50 20 25 0 −100 0 35 50 1 divide row 1 by 20 −200 0 −→ 50 0 Ohio University – Since 1804 Winfried Just, Ohio University 1.25 −100 35 2.5 −200 50 Department of Mathematics MATH3200, Lecture 15: Linear Combinations Gaussian elimination for Homework 29, continued 1 0 0 1 0 0 1.25 −100 35 1.25 1 35 1 0 0 2.5 1 divide row 2 by -100 −200 0 −→ 50 0 1.25 1 35 2.5 2 50 2.5 subtract 35(row 2) from row 3 1 1.25 0 2 1 −→ 50 0 0 1.25 1 0 2.5 1 divide row 3 by -20 0 2 −→ −20 0 Ohio University – Since 1804 Winfried Just, Ohio University 1.25 1 0 2.5 2 −20 2.5 2 1 Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin is out of luck Marilyn has found the augmented matrix 1 1.25 2.5 ~ 1 2 Ab = 0 0 0 1 of the equivalent system x1 + 1.25x2 = 2.5 x2 = 2 0=1 This system is inconsistent. Marvin cannot compose his meal without adding some Losit-Fast. Or so Marilyn says. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin is not conceding yet Marvin: (looking dejected) ”Ok, we can’t figure it out with your Gaussian elimination. But what if we approach the problem from my angle and look for coefficients of a linear combination instead?” Marilyn: ”Er, well, ... I don’t really understand your linear combination stuff. Can you explain it to me?” Marvin: (becomes animated again) “This is really quite simple. It works like this: If you have any vectors ~v1 ,~v2 , . . . ,~vn and another ~ , then w ~ is a linear combination of ~v1 ,~v2 , . . . ,~vn if, and vector w only if, there exist numbers (or as the textbook says, scalars) d1 , d2 , . . . , dn such that ~ .” d1~v1 + d2~v2 + · · · + dn~vn = w Marilyn: “Can you give me an example?” Marvin: Sure. Let ~vQ ,~vF ,~vE ,~vM be the vectors of amounts of sugar, protein, and fat in one serving of Losit-Quick, Losit-Fast, Losit-Easy, and in the meal that each of us needs to compose. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin explains it really nicely Marvin: “Then ~vQ + 2~vF = ~vM . So if we let d1 = 1, d2 = 2, then we see that ~vM is a linear combination of ~vQ and ~vF .” Marvin continues: “We can look at this coordinate by coordinate. 20 ~vQ = 200 20 15 ~vF = 50 40 25 ~vE = 150 60 ~vM 50 = 300 100 So we have 20 15 d1 20 + d2 15 50 d1~vQ + d2~vF = d1 200 + d2 50 = d1 200 + d2 50 = 300 = ~vM 20 40 d1 20 + d2 40 100 When d1 = 1 and d2 = 2 it all adds up.” Marilyn: “Wow! Can you write this for me as a system of linear equations? You know, I find systems easier to understand.” Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin translates it into systems Marvin: “When we look at the coordinates that give us the amounts of sugar, protein, and fat one by one, we get the following system of linear equations:” 20d1 + 15d2 = 50 200d1 + 50d2 = 300 20d1 + 40d2 = 100 (the total amount of sugar) (the total amount of protein) (the total amount of fat) Marilyn: “Could I use x1 , x2 instead of d1 , d2 here?” Marvin: “Absolutely! You see, it doesn’t matter which letters you use for your variables. These are just names.” Marilyn: “So the coefficients d1 = 1, d2 = 2 that you showed me here are precisely the numbers that I got from my solution of the system by Gaussian elimination?” Marvin: “Right!” Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin’s meal Marilyn: (with a sly smile) “So how about your meal?” Marvin: “I need coefficients d1 , d2 such that d1~vQ + d2~vE = ~vM . We can look at this coordinate by coordinate.” 20 25 d1 20 + d2 25 50 d1~vQ +d2~vE = d1 200 +d2 150 = d1 200 + d2 150 = 300 = ~vM 20 60 d1 20 + d2 60 100 Marvin: ”Since you like systems better ... ” Marilyn: “And I like x1 , x2 better than d1 , d2 .” Marvin: (ever the gentleman) “We will write it as” 20x1 + 25x2 = 50 200x1 + 150x2 = 300 20x1 + 60x2 = 100 (the total amount of sugar) (the total amount of protein) (the total amount of fat) (A moment of profound silence ... ) Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin’s meal, Plan B. Solution of Homework 30 Marvin: (Deep breath. Takes it like a man.) “Now you can see that my approach is really the same as yours, only using a more condensed notation and different terminology. Since the system is inconsistent, we will need to use ingredient Losit-Fast. We can find the serving sizes x1 , x2 , x3 by solving the following system:” 20x1 + 15x2 + 25x3 = 50 200x1 + 50x2 + 150x3 = 300 20x1 + 40x2 + 60x3 = 100 (the total amount of sugar) (the total amount of protein) (the total amount of fat) Marilyn interjects: ”By using Gaussian elimination.” Marvin: ”We can leave this an an exercise for the students. I can see right off the bat that the solution is x1 = 1, x2 = 2, x3 = 0.” (It dawns upon Marvin what x3 = 0 means. No beer-flavored Losit-Easy. Long and profound silence ... ) Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin’s meal, Plan C. Maybe. Marilyn: (soothingly) “Maybe there is a different solution?” Homework 31: Solve the system on the previous slide by using Gaussian elimination. Determine all solutions. Marilyn: (gently) “Should we try your approach?” Marvin: (with a glimmer of hope returning to his face) “Good idea. Let’s assume that [y1 , y2 , y3 ]T is a different solution. Then ~vM can be expressed as a linear combination of ~vQ ,~vF ,~vE in at least two different ways:” x1~vQ + x2~vF + x3~vE = ~vM = y1~vQ + y2~vF + y3~vE . Marilyn: ”When we subtract the right-hand side from the left-hand side, ~vM cancels and we get (x1 − y2 )~vQ + (x2 − y1 )~vF + (x3 − y3 )~vE = ~0, where ~0 is the zero vector that has entry 0 in all coordinates.” Marvin and Marilyn: “What does this tells us about the meal?” Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Marvin’s meal, Plan D. Marvin: ”We can simplify the notation by writing the equation (x1 − y2 )~vQ + (x2 − y1 )~vF + (x3 − y3 )~vE = ~0, in the form c1~vQ + c2~vF + c3~vE = ~0, where c1 = x1 − y2 , c2 = x2 − y2 , c3 = x3 − y3 .” Marilyn: ”If [x1 , x2 , x3 ]T and [y1 , y2 , y3 ]T are really different solutions, then not all of the constants c1 , c2 , c3 can be zero.” Marvin: ”So this means a second solution can exist only if the vectors ~vQ ,~vF ,~vE are what is called linearly dependent. But how can we find out whether or not this is the case?” Marilyn: ”We could use Gauss ...” (senses a looming relationship crisis and bites her tongue) “You know what, Prof. Just is going to teach us some great methods for determining linear dependence in a few days. So how about postponing the diet and having some burgers with fries” Marvin: “and a couple of beers!” Just, Ohio University Ohio University – Since Winfried 1804 MATH3200, Lecture 15: Linear Combinations Department of Mathematics Homework problems Our protagonists enjoy the restored harmony of their relationship in a friendly neighborhood pub. Let’s not intrude and get back to work. Perhaps we will meet them again some other day. Homework 32: What does the solution of Homework 31 tell you about linear dependence of the vectors ~vQ ,~vF , and ~vE ? Homework 33: To spare Marvin the ordeal of ingesting Losit-Fast or doing without Losit-Easy, our couple will buy another product from the company. Let’s call it Losit-Other. There are many options, and our protagonists will look at the corresponding vector ~vO first. By now they know that in order for Marvin to be able to combine Losit-Other with Losit-Quick and Losit-Easy for meals to his liking, this vector must satisfy several conditions. How can these conditions be expressed in the language of linear combinations? Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Linear combinations: The definition Definition ~ is a linear combination of vectors ~v1 ,~v2 , . . . ,~vn if there A vector w exist scalars d1 , d2 , . . . , dn such that ~ = d1~v1 + d2~v2 + · · · + dn~vn . w The vectors in the above definition must all be of the same order to make addition meaningful, but they could be either row vectors (of order 1 × m) or column vectors (of order m × 1). Their common dimension m can be smaller than, equal to, or larger than n. The zero vector ~0 of a given order is always a linear combination of any nonempty set of vectors {~v1 ,~v2 , . . . ,~vn } of the same order, as we can choose the coefficients dj in the above definition to be all 0. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations An example of linear combinations: A bee Assume a bee colony nests in a hollow tree. Let [0, 0, 0] denote the position of the hive. A foraging bee travels t1 = 3 time units in the direction of vector ~v1 = [2, 3, 0.5] and then t2 = 2 time units in the direction of vector ~v2 = [0, −2, −0.5] and discovers some tasty blossoms on another tree. We can express the position of these blossoms as the linear combination ~ = t1~v1 + t2~v2 = 3[2, 3, 0.5] + 2[0, −2, −0.5] = [6, 5, 0.5]. w On the way back to the hive, our foraging bee discovers a better route to the blossoms, and upon return to the hive, she shares this info with her sisters by performing a wiggle dance. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Two sisters After the dance, sister Beezee of the foraging bee travels first t3 time units in the direction of vector ~v3 = [1, 1, 0.2] and then t4 time units in the direction of vector ~v4 = [2, 1, −0.3], while sister Buzzy travels first t5 time units in the direction of vector ~v5 = [3, 3, 0.2] and then t6 time units in the direction of vector ~v6 = [0, −1, −0.1]. Homework 34: (a) One of the two sisters didn’t pay attention during the wiggle dance and never found the blossoms. Which one was it, and how can you tell? (b) How long did it take the other sister to arrive at the blossoms? Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Another example: A chemical reaction network Assume a vat contains a mixture of chemical compounds (or, more generally, species) A, B, C , D. Chemists know that the following reactions could in principle occur: −→ A + 2B ←− 2C −→ A + 2C ←− 2D −→ A + B ←− D −→ B + D ←− 2C Homework 35: If the compounds in this system were oxygen O2 , carbon monoxide CO, carbon dioxide CO2 and carbon C, how would these match to the letter symbols A, B, C , D above? Which directions of the above reactions would be ergetically implausible under normal conditions? We will from now on just work with letters A, B, C , D that could represent various chemical species and assume that each reaction could proceed in either direction. Just, Ohio University Ohio University – Since Winfried 1804 MATH3200, Lecture 15: Linear Combinations Department of Mathematics Hint for Homework 35 If the chemical species in this system are oxygen O2 , carbon monoxide CO, carbon dioxide CO2 and carbon C, the only possible reactions are −→ O2 + C ←− CO2 −→ O2 + 2C ←− 2CO −→ O2 + 2CO ←− 2CO2 −→ C + CO2 ←− 2CO Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Acknowledgement This example is loosely adapted from Gerhard Just et al. (1988) Mathematik für Chemiker. (Mathematics for Chemists.) 3rd edition. VEB Deutscher Verlag für Grundstoffindustrie. It was developed by our family business in discussions with the first author of this book. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations A chemical reaction network, continued Chemists know that the following reactions could in principle occur: −→ A + 2B ←− 2C −→ A + B ←− D −→ A + 2C ←− 2D −→ B + D ←− 2C However, they do not know which of these reactions actually occur and want to figure it out by observing how the the concentrations change over time. The initial concentrations (in moles per volume of the vat) will be denoted by [A]0 , [B]0 , [C ]0 , [D]0 . Now suppose concentrations are measured again after one hour and denoted by [A]1 , [B]1 , [C ]1 , [D]1 . ~ = [[A]1 − [A]0 , [B]1 − [B]0 , [C ]1 − [C ]0 , [D]1 − [D]0 ]. Let w ~ represents the net change in concentrations. If The vector w some coordinate [X ]1 − [X ]0 is positive, then a net production of compound X was observed, if some coordinate [X ]1 − [X ]0 is negative, then a net consumption of compound X was observed. Ohio University – Since Winfried 1804 Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Which reactions do occur? −→ A + 2B ←− 2C −→ A + 2C ←− 2D −→ A + B ←− D −→ B + D ←− 2C Chemists know that only the above reactions could occur, but suspect that not all of them in fact do. (When) can one deduce, based exclusively on observing the ~ of net change of concentrations, that at least one, vector w at least two, or at least three of these reactions do occur? (When) can we further narrow down the possibilities based on energetic constraints that rule out one direction for each of the four reactions? Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Vectors for each reaction 1 2 3 4 −→ A + 2B ←− 2C −→ A + 2C ←− 2D −→ A + B ←− D −→ B + D ←− 2C Consider the vector ~v1 = [−1, −2, 2, 0]. This vector represents the net change in concentrations if only the first reaction occurs and consumes one mole of the first reactant, which is compound (or species) A in this case. Homework 36: (a) Find analogues ~v2 ,~v3 ,~v4 of the vector ~v1 for reactions 2, 3, and 4. (b) How is the vector ~ = [[A]1 − [A]0 , [B]1 − [B]0 , [C ]1 − [C ]0 , [D]1 − [D]0 ] w related to the vectors ~v1 ,~v2 ,~v3 ,~v4 ? Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Systems of linear equations as linear combinations Consider a system of linear equations a11 x1 + a12 x2 + · · · + a1n xn = b1 ... am1 x1 + am2 x2 + · · · + amn xn = bm Let ~a1 , . . . , ~an be the column vectors of the coefficient matrix A, and let ~b be the column vector that represents the right-hand side: a11 ~a1 = ... am1 a12 a1n ~a2 = ... . . . ~an = ... am2 amn b1 . ~b = .. bm Then the above system can be written as x1~a1 + x2~a2 + · · · + xn~an = ~b. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Systems of linear equations as linear combinations Consider a system of linear equations 6x1 − x2 + x3 = 5 x2 − 7x3 = 0 −x1 + 2x2 − 3x3 = 9 Homework 37: Find vectors ~a1 , . . . , ~an such that the above system can be written in the form x1~a1 + x2~a2 + · · · + xn~an = ~b. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Consistency of systems and linear combinations a11 x1 + a12 x2 + · · · + a1n xn = b1 ... am1 x1 + am2 x2 + · · · + amn xn = bm Let ~a1 , . . . , ~an be the column vectors of the coefficient matrix A, and let ~b be the column vector that represents the right-hand side. By writing the system as x1~a1 + x2~a2 + · · · + xn~an = ~b we essentially get a one-line proof of the following result: Theorem In the notation introduced above, the system of linear equations is consistent if, and only if, the vector ~b is a linear combination of the vecors ~a1 , ~a2 , . . . , ~an . Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations Solutions of systems and linear combinations a11 x1 + a12 x2 + · · · + a1n xn = b1 ... am1 x1 + am2 x2 + · · · + amn xn = bm Let ~a1 , . . . , ~an , ~b be as on the previous three slides. By writing the system as x1~a1 + x2~a2 + · · · + xn~an = ~b, we also see that solving the system is the same as finding all vectors of coefficients x1 , x2 , . . . , xn that work for the linear combination. Homework 38: Reread the story of Marilyn and Marvin and convince yourself that Marilyn had known this all along. Ohio University – Since 1804 Winfried Just, Ohio University Department of Mathematics MATH3200, Lecture 15: Linear Combinations