computer science
Homework 8
Suggested due date: November 2, 2021, Last day to turn in without penalty: November 7
For the SageMath questions (problems 1-3), you may go to https://sagecell.sagemath. org/. Then copy your code and output to another file (for your convenience, you can put it in the Colab file, even though running the code doesn’t work there). For a Google Colab starter file for the problems using numpy (problems 4-6), go to https://colab.research. google.com/drive/1GR5ANoQJUDJ1ITzOj8oepTXa0AGJJ8Pp?usp=sharing.
1. Solve the following equations or systems in SageMath.
a) x + 2 = 0
b) x2 + 2x + 1 = 0
c)
9x + 3y + 4z = 7
4x + 3y + 4z = 8
x + y + z = 3
2. Find the derivatives of the following functions:
a) x2
b) sin x
c) sin(xex)
3. Find the integrals of the following functions. If the function is not integrable, do a numerical approximation of the integral from 0 to 1.
a) x2
b) sin x
c) x sin x
4. Form a numpy array that consists of the numbers from 0 to 10 in increments of 0.01; that is 0.0, 0.01, 0.02, . . . 9.99, 10.0. Be sure to include 10.0! Also, make sure your code works if we change the lower and upper bounds, and the increment.
5. Write code to do the following:
1
a) Make a numpy array to represent the following matrix:
1 2 34 5 6
7 8 9
.
b) Find the average of each row in the matrix (be sure to find only row averages, not the average of the entire matrix!). Also make sure your code is general enough so that if the matrix is changed, it still works.
6. Suppose you save amount per year = $1,000 each year, and put it in a savings account that gives you interest = 5% interest per year. How much money would you have at the end of num years = 30 years (you put in $1,000 the first year, but don’t add in the amount for the 31st year)? Make sure your code works if you change each of the variables above.
For example, on the first $1,000 you deposit, it will eventually be worth (1.05)30 ∗ 1000 after 30 years. The next $1,000 you deposit will eventually be worth (1.05)29 ∗ 1000, since it had 1 fewer year to collect interest. Add all these numbers up to get the total.
2