You are on page 1of 7

Solving Systems of Equations Using Mathcad

Charles Nippert This set of notes is written to help you learn how to solve simultaneous equations using Mathcad. You will solve a system of 2 simultaneous linear equations using successive approximations or by using the symbolic processor. The methods you will use can be easily adapted to other systems of equations. For this quick tour you will solve the following system for F and T when B is 6. F=T+B 0.75F = 0.3T + 0.95B The first equation represents a total material balance around a process. The second equation represents a material balance of one of the species in the streams Mathcad has two convenient procedures for solving systems of equations. One method uses symbolic manipulation (rearranging the equations and eliminating terms as you would do if you were to solve the equations with pencil and paper). The other method uses successive approximations (making a series of better guesses until the answers are close enough). Solving A System of Equations By Symbolically 1. Open Mathcad as you do normally. Begin by entering the value of the constant, B.. Move the red cross to a spot about inch below the menu bar and about inch from the left hand side of the window on a normal sized screen using either the arrow keys or the mouse cursor. Next type B (remember to use upper case letters. Then choose View/Toolbars/Evaluation from the menu and select the button (alternately, use the shortcut key :. Finally, enter the value 6. Your screen should resemble figure 1. Figure 1 After Step 1

Writing the equation 2. The equations that you are going to enter will be part of a "solve block". This block isolates the equations and other information that Mathcad is going to use in a particular operation from the rest of the information on the worksheet. The start of the block is always marked by the word given which is directly typed onto the worksheet. The word "given" is not part of any comment or text that the program ignores but rather one of the statements Mathcad uses when processing your equations. In most versions of Mathcad, comments appear in Arial font and Mathcad statements such as "given" appear Times New Roman. Press enter and type the word "given" below the equation you just entered. The word will appear inside the rectangular box as shown in figure 2 Figure 2 Given marks the beginning of the solve block

3. Now enter the first equation, F = T + B. Press enter and type F just below the word given. Next choose View/Toolbars/Boolean from the menu to open the Boolean toolbar. Click the button in the Boolean toolbar to create the equals symbol. Type T + B using the keyboard. Press enter and enter the second equation. Remember to use the * key to indicate multiplication. Your screen should look like Figure 3 after you entered both equations.

Figure 3 After Entering Both Equations

4. You will now mark the end of the solve block and tell Matchcad which of the variables (F,B or T) it should attempt to calculate. You will also tell Mathcad to use the symbolic processor to find a solution. Both of these instructions are built into one statement that uses the mnemonic find which is easy to remember because you want the program to find a solution. Finish the solve block by moving mouse cursor directly below the equation and button on typing "find (F, T) ". You can create the arrow operator using the the Evaluation toolbar. When you have completed the expression press "Enter". The solution should appear to the right of the arrow. Your screen should look like Figure 4. The top value (8 2/3) is the value of the first variable (F) and the second value (2 2/3) is the value of the second variable (T).

Figure 4 Find the Solution to a System of Equations

Solving A System of Equations By Successive Approximations The method of successive approximations starts with guesses values for each unknown, then using an algorithm or set of rules to improving those guesses until the guesses become good enough. The set up for solving a system of equations by successive approximations is very similar to the setup for solving equations by symbolic manipulation. The major differences are that initial guesses of the unknowns must be specified and the button instead of the button on the evaluation toolbar. To emphasize how similar the setups are, you will modify the solution from the previous setup to use the numerical method of successive approximations. 5. Move the red cross cursor to a spot above the word given. Enter the values F= 5 and T = 10. Use the button on the Evaluation toolbar or the : key to create the assignment symbol in both expressions. Your worksheet should now look like Figure 5

Figure 5 Enter the First Guesses of the Unknown Variables

6. Now, replace the arrow (used to solve symbolically) Move the mouse cursor over the matrix with the answers and click the left moose button. A blue cursor will appear as shown in Figure 6 Figure 6 The Blue Cursor Appears in the Solution Matrix

7. Now drag the mouse while holding the left mouse button until the entire matrix is shown in inverted colors (black background and white letters) as shown below Figure 7 Highlight the Matrix

8. Press the Delete key. The matrix and the arrow should disappear. Type = or use the button and the solution will appear as shown in Figure 8

Figure 8 The Solution Using Successive Approximations

Tips on Using Each Method Each method has its own advantages and disadvantages. Successive approximations work best when good first guesses are used. Successive approximation methods may have difficulty finding complex solutions unless the initial guesses are complex. On the other hand, the symbolic solver will find multiple roots of quadratics but may have difficulty with some nonlinear systems. Figure 9a illustrates how the symbolic processor finds the complex roots of a quadratic Figure 9a Finding Complex Roots Using the Symbolic Processor

The successive approximation solution requires a complex initial guess to converge as shown in Figures 9b and 9c

Figure 9b Failure of Successive Approximations with a real Initial Value

Figure 9c Successive Approximations Finds a Root When a Complex Initial Value Is Used

To reset the criteria for successive approximations, select Math/Options from the Menu toolbar. A dialog box opens as shown in Figure 1. Set the Convergence tolerance to the desired value Figure 10 The Math Options Dialog

You might also like