8.5

## Lab 7, CSC430, Spring 2022

### 1Developing Functions

In the exercises below, any instruction to "develop a function" implies the following steps:

1. Deciding what kind of data the function will accept,

2. Writing the first line of the function including the function name and parameter names,

3. Adding a docstring that indicates the purpose of the function,

4. Writing test cases for the function using assert (except when indicated below), and finally

5. Writing the body of the function.

### 2SymPy + NumPy

Consider the following set of linear equations:

3x + y - z = 9 x + 2y + z = 4 4x - 7y + 0z = 1

First, develop three functions, eq1, eq2, and eq3 that represent the three equations above. Specifically, they should accept values for x, y, and z, and return true if the computed left side of the equation is within 10^{-9} of the right side. Then, develop the eq123 function that accepts values for x, y, and z and returns true if all three of the equations are satisfied (use the functions you just developed for this!). You do not need to write a test case for the eq123 function.

Next, use sympy to solve these three sets of equations. Print out the generated solution. Then, write a test case that supplies the given values of x, y, and z to all3 to see whether the given solution actually works.

Finally, use numpy to solve these equations using linalg.solve, as in earlier labs. Check that these solutions are the same.

### 3SymPy

For each of the following, use sympy to determine a set of solutions. For each set of solutions, provide at least two examples of solutions when there is more than one possible.

1. x = 3x + 4y + z 4z^2 = 9x + y

2. \frac{x^6 + 9y}{z + x} = 44z^8 e^x = 9