You are on page 1of 11

3: Solving Equations

Solving Equations Manually 1 Goal Seek 2 Solver 3 Solver Example 3 Solver with Constraints 4 Simultaneous Equations 5 Linear programming 6 Another Linear Programming Problem 8 A Quadratic Equation Solver 10 Protecting your work 11

Solving Equations Manually


We begin by re-examining the problem at the end of page 12 in Quantitative Approaches in Business Studies: the selling price of an item, including 17.5% VAT is 16.00, what is the price before tax? We can solve this algebraically. Let the pre-tax price be x. 17.5x x + 17.5% x = 16 or x + = 16 100 117.5x = 16 100 100 x = 16 = 13.62 117.5 Suppose we did not wish to perform the algebra (with more complex problems, the algebra may be beyond our ability). We can still use Excel to solve an equation by a process of repetitive guessing. The worksheet in Figure 1 has been set up to solve the current problem.
A B Solving an equation by guessing pre-tax price VAT tax after-tax price 10.00 17.5% 1.75 11.75 C

1 2 3 4 5 6

=B3 * B4 =B3 + B5

Figure 1 In B3 we have entered our initial guess of 10.00 and formatted the cell with the Currency tool. In B4 we have entered the VAT rate of 17.5% which we enter by typing 17.5 followed by the percentage sign from the top row of the keyboard. The other, less convenient, way is to recognize that 17.5% means 17.5/100 or 0.175, so we may enter 0.175 in the cell and then format it with the percentage tool. Cell B5 contains the formula =B3*B4 to compute the tax while B6 computes the after-tax figure using =B3+B5. We can now use trial-anderror to vary the value in B3 until we get the required value of 16.00 in B6. Did you find the pre-tax value to be 13.62? With such a simple problem, this method would seem to have little merit since the algebraic method is so straightforward. However, this method can be used with problems

2 Solving Equations when the algebra is less tractable. Furthermore, it sets the scene to introduce two features of Excel: Goal Seek and Solver.

Goal Seek
We solved the problem above by making repeated guesses. When the result in B6 was far from the required value of 16.00 we made large adjustments to B3; as we got closer to the required value we made smaller corrections. All of this takes some time. The programmers who developed Excel saw the need to automate this activity and gave us Goal Seek. To see how it works return to the worksheet shown in Figure 1 and make sure you have the value 10.00 in B3. Use the command Tools|Goal Seek... to bring up the dialog box shown in Figure 2. Complete the dialog box as shown: we want B6 to acquire a value of 16 by varying the value in B3. Note that you need not type the $ symbols. Either type the cell references or point to the cells as explained in the Formulas and Functions chapter of this supplement, and Excel will add the $s. When you are ready, press the OK button on the dialog box. The Goal Seek Status dialog box appears (Figure 3) to show you the result click on its OK button.

Figure 3

Figure 2 The Goal Seek Status dialog box has buttons labelled Step and Pause. It is doubtful if you will ever get to use these because, with modern computers, Goal Seek solves all but the most complex problems in a very short time. Suppose we wish to solve a quadratic equation such as 2x2 !5x !3 = 0. We could solve this algebraically using the quadratic formula which, in general, will give two roots. So what will Goal Seek do? It will give the root closest to your starting guess. Try this out with a worksheet similar to that in Figure 4.

Solving Equations 3
A 1 Quadratic 2 x 3 function B C D

1 -6 =2*G2^2-5*G2-3

Figure 4 The Set cell for Goal Seek will be B3, the To value will be 0 and the By changing cell will be B2. With an initial value of 1, Goal Seek reports that it found a solution with x = !0.4999999... which makes B3 equal to 5.8E-05. The mathematical method used by Goal Seek sometimes results in values that are not quite exact. We asked to have B3 set to zero, Goal Seek has settled for !5.810-5, a value that is small but not exactly zero. The value of x should have been exactly !0.5. If you give B2 a starting value of 10, Goal Seek will find a solution with x = 3.00002 which gives the function a value of 0.000143. Again, not an exact result but close. A quadratic problem was chosen to demonstrate Goal Seek since most readers will be familiar with this type of equation. However, since it is possible to get the exact solution using the quadratic formula, it is better to set up a worksheet that uses this see the end of this unit.

Solver
The Goal Seek feature is fine for very simple problems but it has been superceded by a newer feature called Solver. Solver can do everything that Goal Seek can do and much more. Goal Seek lets you adjust one cell to produce a specific value in the target cell. Solver lets you adjust one or more cells to produce a maximum, a minimum or a specific value in the target cell. Furthermore, Solver allows you to set constraints. For example, you can require a variable cell to have a positive value. In addition, for every worksheet, Excel remembers the parameters last used for a Solver problem. First we must make sure that your copy of Excel is set up to use Solver. Click on the Tools menu item and look for Solver in the drop down menu. If you see it, press E. If you do not see it, click on the Add-ins item of the Tools menu and click in the box beside Solver Add-in. In the event that this is not present in the dialog box you will need to re-install Excel specifying that you want to include Solver.

Solver Example
We will solve the percentage problem using Solver to show how easy it is to use. Set up the same worksheet as before. Start with the value 10 in B3. Now invoke Solver with the command Tools|Solver. Complete the dialog box as shown in Figure 5. When ready, click on the Solve button on the dialog box. The Solver Results dialog box appears (Figure 5). Click on the OK button. We do not have space here to examine the options on the result box. You may wish to read Help, or just to experiment, to learn what the reports are.

4 Solving Equations

Figure 5

Figure 6

Solver with Constraints


We saw that, when a problem has more than one solution, Goal Seek finds the one (algebraically) closest to the starting value. Solver behaves the same way. However, we can impose constraints on Solver. As an example, we will find the positive root of the quadratic equation 2x2 !5x !3 = 0. Begin with the worksheet shown in Figure 4. Use Tool|Solver and complete the dialog box as shown in Figure 7. To add the constraint, click on the Add button in the Solver Parameters box to open the add Constraint dialog (Figure 8.) Fill in the constraint (B3 >= 0) and click the OK button on the box. The Add button on the add Constraints box is used when you wish to add more than one constraint. On the Solver Parameters box, press Solve. Solver finds the positive root x = 3. Note that Solver is more accurate than Goal Seek.

Solving Equations 5

Figure 7

Figure 8

Simultaneous Equations
In Chapter 1 (page 23) of Quantitative Approaches in Business Studies, the author shows how to solve simultaneous equations algebraically. We can also use Solver to find the roots of simultaneous equations also called systems of linear equations. We will show how to solve a problem with three unknowns but the method can be adapted for other problems. Our example will be: 2x + 3y ! 5z = 18 3x + 5y + 2z = 19 x ! 4y + 3z = !13 This system may be written in the form: 2x + 3y ! 5z !18 = 0 3x + 5y + 2z !19 = 0 x ! 4y + 3z +13 = 0 We may consider each equation to have the form ax + by + cz + d = 0 where a, b, c are called the coefficients and d the constant term. We begin by setting up the worksheet as shown in Figure 9. Values of 1 are assigned to the three unknowns as the starting values for Solver to work with. The values of the coefficients and constants for each equation are entered in A7:D9. In E7 we enter the formula =A7*$A$4+B7*$B$4+C7*$C$4+D7. The use of absolute references permits us to copy this down to row 9. When the correct values of x, y and z values are entered into A$:C4, the function values in E7:E9 will evaluate to zero.

6 Solving Equations
A B 1 Simultaneous Equations 2 3 x y 4 1 1 5 6 a b 7 2 3 8 3 5 9 1 -4 10 C D E

z 1 c -5 2 3 d -18 -19 13 SumSq function -18 -9 13 574

Figure 9
A B 1 Simultaneous Equations 2 3 x y 4 2 3 5 6 a b 7 2 3 8 3 5 9 1 -4 10 C D E

z -1 c -5 2 3 d function -18 2.35E-07 -19 -6.8E-07 13 -6.6E-09 SumSq 5.17E-13

Figure 10 But how can we get Solver to do this? Solver can handle more than one variable cell but only one target cell. Our first inclination might be to say: If E7, E8 and E9 are to be made equal to zero then SUM(E7:E9) is to be made zero also. On reflection this is incorrect, the sum could still be zero if the three have a mixture of positive and negative values such as 6, 3 and !9. There are two possible ways around this. We could sum either the absolute values of E7:E9 or their squares because only individual zero values will then sum to zero. We opt for the second way since it is easy to do in Excel. In E10 enter the formula =SUMSQ(E7:E9). Now we are ready to work with Solver. The Set target will be E10, which we require to have a Value of 0, By changing A4:C4. When we click the Solve button, Solver reports it has found a solution with values of 2, 3 and -1 for x, y and z, respectively as shown in Figure 10. But does each equation evaluate to zero? Not exactly. Once again we have what computer scientists call round-off error. If you make A4 the active cell and look at its value in the Formula bar you find that Solver has given it a value of 1.9999999793161 which rounds to 2. Solver is not perfect but if we had a number of systems of equations to solve it would quickly give us the answers.

Linear programming
Solver may be used to do maximisation/minimization problems of the type generally called linear programming. This is covered in Chapter 19 of Quantitative Approaches in Business Studies. Lanark Fabrication Plc, a small operation run by students working part-time, makes two models of wheelbarrows. The Standard model nets the company i60 in profit while the Deluxe model nets i80. A Standard model uses 2.0 hours of the construction time and 1.5 hours for painting and packing. The Deluxe model needs 3.0 hours for construction and 0.8 hours for painting and packing. The workshop has weekly resources for a total of 100 hours of construction time and 50 hours for painting and packing. What mix of product

Solving Equations 7 models will maximize the profit? The problem is set up as shown in Figure 11. There are three areas in the worksheet: Variables, Maximization and Constraints. In the Variables area we have a value for each variable in the problem. In this case the number of wheelbarrows of each type to be made. We may put any value here initially, a value of 1 has been used. In the Maximization area we enter the parameters related to the quantity to be maximized (the profit). We enter the values for the unit profit in C8 and C9. In D8 we compute the profit for the Standard model with the formula =C8*C4 and copy this to D9 to compute the profit on the Deluxe model. Finally, in D10 we compute the total profit with = D8+D9 or =SUM(D8:D9). Similarly, in the Construction part Constraints area, C14:C15 hold the unit times, D14:D15 computes the totals with formulas such as =D14*C4 and in D16 the total construction time is found with =D14+D15. The maximum available time is entered into D17. The Paint and Packing area has analogous values and formulas.
A B Linear programming Variables C D E F G H I

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Model Number Standard 23 Deluxe 18

Maximization Unit Profit Standard 60.00 1,380.00 Deluxe 80.00 1,440.00 Total 2,820.00 Constraints Construction Standard Deluxe Total Max

Unit 2 3

Time 46 54 100 100

Paint & Packing Unit Standard Deluxe Total Max

Time 1.5 0.8 34.5 14.4 48.9 50

Figure 11 Solver is set up as shown in Figure 12. We wish to maximize the profit value (D10) by changing the number of units of each model (C4:C5) subject to the constraints that the total Construction and Paint & Packing times cannot exceed the maximum values (D16<=D17 and I16<=I17). Solver reports that the profit is maximized by making 24.14 Standard and 17.24 Deluxe models. You may wish to add two more constraints to require integral (whole number) values since we cannot sell incomplete wheelbarrows. We then get a mix of 23 Standard and 18 Deluxe models. Note that there is now some unused Paint & Packing time. It is sometimes necessary to add a third set of constraints if Solver returns a nonsense solution requiring meaningless negative values for the variable. For example we might add the constraints C4>=0 and C5>=0. It is best to work with the minimum number of constraints adding more only as needed. For a more complex linear programming example, see the authors web site: Bernard Liengme

8 Solving Equations

Figure 12

Another Linear Programming Problem


On page 431 of Quantitative Approaches in Business Studies, question 5 poses a problem about a tea company. Figure 13 shows a worksheet set up to solve this problem.
A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 B C D E F G H I J K L

Foo-Ti Tea Company


Variables Production (kg) Puce 1 Olive 1 T-bags 1 The quantities to be determined

Composition of Products Puce China 2 Indian 4 Ceylon 3 Total 9 Income from Products Puce per 250g 0.36 per kg 1.44 from production 1.44 Puce 0.96 1.44 0.48

Cost of Materials (kg) Olive 1 6 2 9 T-bags 1 5 4 10 China Indian Ceylon 1.20 0.80 1.00

Cost of Material for production run Puce Olive T-bags Total 0.27 0.13 0.12 0.52 0.36 0.53 0.40 1.29 0.33 0.22 0.40 0.96 Total 2.76 Maximum 480.00 Quantity to be maximized (profit) Constraint: Total to be spent on raw materials is 480

Olive 0.30 1.20 1.20 Olive 0.89 1.20 0.31

T-bags 0.32 1.28 1.28 T-bags 0.92 1.28 0.36

Total

Profit 1.16

3.92

expense/kg revenue/kg margin/kg

Figure 13 We start with the variables: how many kilograms of each product are to be made. Use 1 as the starting values in B4:D4 it is easier to check your formulas that way. We need the composition of each product in order to compute material costs. This information is in A8:D13. We will be using this table to compute the fraction of each tea in each product. Yes, we could have done this by entering =2/9 , =4/9 and =3/9 in B10:D10, etc. However, it is much better to display all of the original problems data. This can aid you in double checking your work and is essential if you wish to play what-if games.

Solving Equations 9 In F10:G10 we list the unit cost of the starting materials. Note we put the various products in a row and the various materials in a column in A8:D13. If we maintain this pattern (product in rows, material in columns) we will be able to develop formulas that can readily be copied. The objective here is not just to save time. The fewer times you have to develop a formula, the fewer chances there are for errors. In I9:L12 we compute the cost for a production run. The formula in I10 is =G10*B4*B10/B13. This may be read as (Weight of Puce)(Cost of China per kg)(Fraction of Puce that is China). This computes the cost of the China tea in the Puce product. By editing the formula to read =$G10*B$4*B10/B$13, we are able to copy it to the range I10:K12. We should double check the formulas in this range. Double click on them in turn to go into Edit mode and look at the range finders (coloured boxes) on the cells used in the formulas. Check that every formula makes sense. In L10:L12 we use the AutoSum tool to total these costs by row and in L13 we find the overall cost. The problem tells us that the overall cost is not to exceed 480. It is convenient to enter this value in L13. The first half of the problem (costs) has been done. In A16:E19 we concentrate on the other half: revenues. Again note that we have included the problems original data revenue for 250 gm packets and computed the revenue per kilogram and for the production run. The formulas in B18 and B10 are =B17*4 and =B18*B4, respectively. These are copied to column D. We know the cost and the revenue so we may now compute the profit contribution in G17. This will be the quantity that is to be maximized. We can now call upon Solver, setting up its dialog as in Figure 14. The first three constraints are added to prevent nonsense results. The third is part of the original problem set out in the book. Solver finds an unexpected result: it tells the company to make 502 kg of Puce product and none of the other two.

Figure 14 We may wish to further investigate this solution. In A21:A24 we compute the margin on 1 kilogram of each product. The formulas are: B22: =(B10/B13*$G$10)+(B11/B13*$G$11)+(B12/B13*$G$12) B23: =B18 B24: =B23-B22 in B24. These are copied to column D. Now we see why Solver suggests making only Puce it has the highest profit margin. Of course, if the amount of one of the materials was limited we might get a different answer.

10 Solving Equations Incidentally, the sum of B22+C22+D22 should be the same as the value in L13 when the production amounts (B4:D4) are all 1. This can serve as a double check of our formulas.

A Quadratic Equation Solver


From time to time, we need to solve quadratic equations. The standard form of a quadratic 2 equation is: ax + bx = c = 0 . The roots of this may be found using the so-called quadratic formula as shown in Figure 15. There is one important consideration: we cannot 2 find the square root of a negative value. If the quantity b 4ac turns out to be negative, the quadratic equation has not real roots and we do not wish to explore imaginary numbers here! Furthermore if the same quantity turns out to have a zero value then the quadratic equation has only one real root some will argue that it has two identical roots! For this reason the quantity b 2 4ac is called the discriminant.

Figure 15 The user enters the coefficients a, b and c into cells A6:C6. In C9 we compute the discriminant. The formula in C10 tells the user how may real roots the equation has. The formulas in C13 and C14 compute the real roots if they exist. If there is only one real root C14 will be blank. As with any worksheet, we should test this one before using it to solve real problems. We need to make some quadratics whose roots we know. The simplest way is like this: If x = -3, then x - 3 = 0. If x = 1.5, then x - 1.5 = 0 or 2x - 3 = 0. We can make a quadratic equation by multiplying the two equations: ( x + 3)(2 x 3) = 0 or 2 x 2 + 3x 9 = 0 . This is the equation solved in Figure 15. You should make others to test, including some with one root or two identical roots. If you wish to document your worksheet as shown above, the large box was made using the command Insert|Object and selecting Microsoft Equation 3.0.

Solving Equations 11

Protecting your work


You have developed a worksheet (maybe the quadratic equation solver above) and distributed it to colleagues in your office. With in days maybe minutes someone is complaining it is not working. When you check you find they have tampered with an important area of your worksheet. Maybe they have deleted the formula in C9 for the discriminant. How can this be avoided? The answer is to protect your worksheet. This is a simple two-step process. First, decide which cells the user is to be allowed to change (in the worksheet above these would be A6:C6) and unlock these cells. Select the range, use the command Format|Cells, open the Protection tab, and in the resulting dialog box (Figure 16) deselect (i.e. click to remove the check mark) from the Locked box. Secondly, protect the worksheet by using the command Tools|Protection|Protect Sheet. Click the OK button on the dialog box that pops up see Figure 17. Unless you have another copy of the worksheet, it is not advisable to use a password. There are companies that sell password protection decoders. So someone who is intent on finding your secrets will be able to do so. On the other hand, if you forget the password it will cost money to rediscover it.

Figure 16

Figure 17

You might also like