You are on page 1of 5

TI 89 Titanium Exercises - Part 7

Multiple-equation symbolic solution with solve


In Exercise 6 we used function solve with a single equation and variable. In this section, we
show how to solve simultaneous equations for more than one variable. For example, to solve
the system of equations:

X2 + Y2 = 13
X+ Y=5

Use: solve(x^2+y^2=13 and x+y=5, {x,y})

The solutions being: x = 3 and y = 2 or x = 2 and y = 3

A second example:

solve(x+y+z=6 and x^2+y*z=7 and x*y+z^2=11,{x,y,z})

Solution: x = 3 and y = ((17)^1/2+3)/2 and z = -((17)^1/2-3)/2 or


x = 3 and y = -((17)^1/2-3)/2 and z = -((17)^1/2+3)/2 or
x = 2 and y = 1 and z = 3 or
x = 1 and y =2 and z = 3

An example involving an undefined value (two equations, three unknowns):

solve(x+y+z=6 and x+2*y+3*z=7,{x,y,z})

Solution: x = @1 – 9 and y = -(2*@1-15) and z = @1

This solution can be interpreted as: x = z – 9 and y = -(2*z-15). The term @1 represents a
parameter that can be replaced by any value. Thus, the solution above represents a family of
parametric solutions.

For the next example, we repeat the command above but using two unknowns only:

solve(x+y+z=6 and x+2*y+3*z=7,{x,y})

The solution is: x = z – 9 and y = -(2*z-15).

Also, try (only one unknown listed):

solve(x+y+z=6 and x+2*y+3*z=7,x)

The solution is still: x = z – 9 and y = -(2*z-15).

For the next example, we’ll create two equations (using, for example, the equation writer
introduced in Exercise 1), and store them into variables e1 and e2, as shown below:
These are the equations governing energy and uniform flow (Manning’s equation) at the
entrance from a reservoir to an open channel of rectangular cross-section. Typically the
geometry of the section (b = width), the slope of the channel bed (s), the Manning’s resistance
coefficient (n), the available energy head (h), the coefficient of Manning’s equation (c = 1, for
SI, and c = 1.486 for ES), and the acceleration of gravity (g) are known. The solution of the
simultaneous equation is the pair {q,y}, where q is the flow discharge, and y is the flow depth.

To show a solution using function solve, we first need to provide values to the known variables.
Thus, let’s use: b = 2.5 ft, s = 0.0001, n = 0.012, h = 4 ft, c = 1.486, and g = 32.2 ft/s2. We
need to store these values in the corresponding variables, i.e., 2.5 [STO] b [ENTER] 0.0001
[STO] s [ENTER] etc., as shown below:

To build the solution, type e1[ENTER] and e2 [ENTER] to list the resulting equations, i.e.,

Using the CUT and PASTE functions, put together the command:

solve(10=0.002484*q^2/y^2+y and q = 2.6469*y^(4/3)/(y+1.25)^(2/3),{y,q})

i.e., cut and copy the equations shown in the screen above into the solve command. After
pressing [ENTER], you get the following solution (after about 30 seconds):

y = 3.99519 and q = 5.5583 or y = -1.23461 and q = 56.6704


The only solution that is physically possible is that for which y>0, i.e., y = 3.99519 ft and q =
56.6704 ft3/s. We could force this solution by using:

solve(10=0.002484*q^2/y^2+y and q = 2.6469*y^(4/3)/(y+1.25)^(2/3),{y,q}) | y>0

As an alternative approach, you can type the command:

solve(e1 and e2, {y,q})


or
solve(e1 and e2, {y,q}) | y>0

Note: Once values are given the known variables, the equations stored in variables e1 and e2
will be evaluated every time you invoke their name, as shown in the screen above. To recover
the original equations, you need to delete variables c, n, h, s, b, and g. This can be easily
accomplished by using [2nd][F1] (i.e., F6) and selecting 1: Clear a-z, then pressing [ENTER]. If
you now invoke variables e1 and e2 you will have the original equations. To solve a different
problems, store new values of c, n, h, s, b and g, and repeat the procedure shown above.

Exercise:

Solve the problem of the entrance to a trapezoidal channel from a reservoir for which the
equations are:
q2
h= y+
2 g ((b + zy ) y )
2

c ((b + zy ) y ) 4 / 3
q= ⋅ ⋅ s
n (b + 2 y 1 + z 2 ) 2 / 3

Solve the simultaneous equations for h = 4 ft, g = 32.2 ft/s2, b = 2.5 ft, z = 0.75, n = 0.012, s =
0.00001, and c = 1.486.

Note:
An alternative way to solve this system is to solve for q from the first equation, i.e.,

q = 2 g ((b + zy ) y ) 2 (h − y ) = ((b + zy ) y ) 2 g (h − y ) ,

And make it equal to the second equation, resulting in the single equation:

c ((b + zy ) y ) 4 / 3
((b + zy ) y ) 2 g (h − y ) = ⋅ ⋅ s
n (b + 2 y 1 + z 2 ) 2 / 3

which can be solved for y using solve. Once a value for y has been found, the value of q can
be calculated from either equation for q as shown above.

Use of scripts to solve simultaneous equations


Having developed an algorithm for loading and solving simultaneous equation, we could create
a script to execute the commands automatically. A script is similar to a program or function,
except that it doesn’t need to have arguments, nor return a value (or values). A script is just a
collection of commands as you would enter them while interacting with the calculator, stored
into a text file. A script is written by using the Text Editor application in the Apps menu.
Scripts consist of command lines and comment lines. Comment lines are lines of text, where as
command lines contain executable statements. Command lines state with a C:.

As an exercise, we’ll start by creating a script named twoeq as follows:

• Press the [APPS] key, select the Text Editor, and press [ENTER]
• Select 3:New…, and press [ENTER]
• Keep Type: as Text, select the Folder: where you want to store the script, and type
the name of the Variable: as twoeq. Press [ENTER].
• As a result you will get a colon and a blinking cursor. First, enter a title to the script
by typing [ALPHA][ALPHA]Two simultaneous eqns [ALPHA][.] [ENTER]
• To type a command line, use [F2][ENTER] (essentially selecting the option 1:Command)
• Continue typing the script to read as follows (press [ENTER] at the end of each line, use
[F2][ENTER] to type command lines):

• To activate the script, first, move to the top of the script, e.g., using [ ♦ ][S]. Then,
press [F2] and select the option 5:Execute to EOF.
As a result, you will see the commands being executed in the HOME screen, and
stopping with the last one with a BUSY message. When this last command is executed,
then the screen will return to the Text Editor screen.
• Press [HOME] to recover the HOME screen, and press [CLEAR] to ensure that the last
command is not repeated (it takes some time to produce a result).
• Press [S] followed by [ ♦ ][S] to move to the first line of the screen. Then, use [T]
to move down the screen to see all the commands and the results.
• The result, as before is y = 3.99519 and q = 5.55836

Having this script you can modified it to solve other problems that use the same equations but
different values, or even different equations. For example, the exercise proposed above can
be solved by modifying the twoeq script, into the following script, which you can save into a
variable called twoeq2. To copy the script follow these instructions:

• Press [2nd][VAR-LINK].
• Select the variable twoeq, and press [F4] to place a check mark by it.
• Press [F1], and select 2: Copy.
• Select a different folder to copy it
• Rename the variable to twoeq2 by using [2nd][VAR-LINK], selecting the copied
variable, then using [F1] and selecting 3:Rename. Then, type twoeq2 in the To: field
• Press [ENTER].
• At this point, you could copy the rename script back to the original folder. If you
decide to do so, use [2nd][VAR-LINK], select the renamed variable, check it with [F4].
Then use [F1], and select 4:Move. Then select the folder where you want to move it
to, and press [ENTER].

To modify the script:


• Press [APPS], select the Text Editor, and press [ENTER].
• Select 2:Open… and press [ENTER].
• In the Variable field, select twoeq2, and press [ENTER].
• Edit the script to read as follows (press [2nd][INS] to insert characters in the text):

Note: in the call to function solve we have included the option y = 3.9 to start the
numerical solution. Since the depth of flow y in this solution must be smaller that the
available energy head (h = 4 ft), a value of y = 3.9 is a good value to get started.

• To activate the script, first, press [APPS], and select Text Editor. Select 1: Current,
and press [ENTER]. Move to the top of the script using [ ♦ ][S]. Then, press [F2] and
select the option 5:Execute to EOF.
Wait until you’re returned to the script.
• Press [HOME] to recover the HOME screen, and press [CLEAR] to ensure that the last
command is not repeated (it takes some time to produce a result).
• Press [S] followed by [ ♦ ][S] to move to the first line of the screen. Then, use [T]
to move down the screen to see all the commands and the results.
• The result, in this case, is y = 3.93552 and q = 43.7214

You might also like