Skip to content

learn-co-students/dsc-lineq-numpy-lab-onl01-dtsc-ft-052620

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solving Systems of Linear Equations with NumPy - Lab

Introduction

Now you've gathered all the required skills needed to solve systems of linear equations. You saw why there was a need to calculate inverses of matrices, followed by matrix multiplication to figure out the values of unknown variables.

The exercises in this lab present some problems that can be converted into a system of linear equations.

Objectives

You will be able to:

  • Use matrix algebra and NumPy to solve a system of linear equations given a real-life example
  • Use NumPy's linear algebra solver to solve for systems of linear equations

Exercise 1

A coffee shop is having a sale on coffee and tea.

On day 1, 29 bags of coffee and 41 bags of tea were sold, for a total of 490 dollars.

On day 2, they sold 23 bags of coffee and 41 bags of tea, for which customers paid a total of 448 dollars.

How much does each bag cost?

# Create and solve the relevant system of equations
# Describe your result

Exercise 2

The cost of admission to a popular music concert was 162 dollars for 12 children and 3 adults.

The admission was 122 dollars for 8 children and 3 adults in the same music concert.

How much was the admission for each child and adult?

# Create and solve the relevant system of equations
# Describe your result

Exercise 3

You want to make a soup containing tomatoes, carrots, and onions.

Suppose you don't know the exact mix to put in, but you know there are 7 individual pieces of vegetables, and there are twice as many tomatoes as onions, and that the 7 pieces of vegetables cost 5.25 USD in total. You also know that onions cost 0.5 USD each, tomatoes cost 0.75 USD and carrots cost 1.25 USD each.

Create a system of equations to find out exactly how many of each of the vegetables are in your soup.

# Create and solve the relevant system of equations
# Describe your result

Exercise 4

A landlord owns 3 properties: a 1-bedroom, a 2-bedroom, and a 3-bedroom house.

The total rent he receives is 1240 USD.

He needs to make some repairs, where those repairs cost 10% of the 1-bedroom house’s rent. The 2-bedroom repairs cost 20% of the 2-bedroom rental price and 30% of the 3-bedroom house's rent for its repairs. The total repair bill for all three houses was 276 USD.

The 3-bedroom house's rent is twice the 1-bedroom house’s rent.

How much is the individual rent for three houses?

# Create and solve the relevant system of equations
# Describe your result

Summary

In this lab, you learned how to use NumPy to solve linear equations by taking inverses and matrix multiplication and also using numpy's solve() function. You'll now take these skills forward and see how you can define a simple regression problem using linear algebra and solve it with Numpy.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published