7 Solving systems of linear equations

 

This chapter covers

  • Detecting collisions of objects in a 2D video game
  • Writing equations to represent lines and finding where lines intersect in the plane
  • Picturing and solving systems of linear equations in 3D or beyond
  • Rewriting vectors as linear combinations of other vectors

When you think of algebra, you probably think of problems that require “solving for x.” For instance, you probably spent quite a bit of time in algebra class learning to solve equations like 3x2 + 2x + 4 = 0; that is, figuring out what value or values of x make the equation true.

Linear algebra, being a branch of algebra, has the same kinds of computational questions. The difference is that what you want to solve for may be a vector or matrix rather than a number. If you take a traditional linear algebra course, you might cover a lot of algorithms to solve these kinds of problems. But because you have Python at your disposal, you only need to know how to recognize the problem you’re facing and choose the right library to find the answer for you.

7.1 Designing an arcade game

7.1.1 Modeling the game

7.1.2 Rendering the game

7.1.3 Shooting the laser

7.1.4 Exercises

7.2 Finding intersection points of lines

7.2.1 Choosing the right formula for a line

7.2.2 Finding the standard form equation for a line

7.2.3 Linear equations in matrix notation

7.2.4 Solving linear equations with NumPy

7.2.5 Deciding whether the laser hits an asteroid

7.2.6 Identifying unsolvable systems

7.2.7 Exercises

7.3 Generalizing linear equations to higher dimensions

7.3.1 Representing planes in 3D