Getting Started

Since most real-world linear algebra computations are much too large to do by hand, software is essential for practical applications of the material in Math 341. The main software tools that are used are Matlab, Mathematica, and Maple; various extensions of Python; the statistics programming language R; and various low-level languages like C. In this blog, we will use a particular extension of Python, called Sage or CoCalc, for the kinds of computations we are doing in Math 341.

This post contains detailed instructions for creating your first worksheet on CoCalc. It should take you about 15 minutes to work through. (Click on any of the screen shots below for a bigger version.)

  1. Visit https://cocalc.com. You will see a screen where you can create an account:
    Fill out the form, using a real e-mail address, and you have an account.
  2. You will be taken to a screen where you see a list of projects (currently empty):

    Type in a title for your new project and click “Create Project”:
  3. Next, add a new worksheet: click “Create or upload files”: Give it a name (like “Week1”) and choose “SageMath Worksheet”:
  4. Now we’re in a Sage worksheet; your screen should look like this: Type “2+2” and press Shift-Return. (That is, hold down the Shift key and press Return.) Sage should compute “4” for you:
  5. Okay, not so impressive so far. The worksheet has some menus to help you get started with Sage syntax. Let’s try graphing a function. From the “Plots” menu select “Function”. Then press shift-return. You should see a plot of the function.

    Play around with the function, and press shift-return to get a new plot. Sage can also do 3D plotting:
  6. Time for some linear algebra. Type:
    %var x y
    solve([3*x+5*y==7, x-2*y==3],x,y)


    The first line tells Sage that x and y will be variable names. The second says to solve the pair of equations 3x+5y=7 and x-2y=3 for x and y. (Note the two equal signs in each case.) I will talk about the syntax a little more in a future post.
  7. Try solving a few of your homework problems (or other textbook problems) with Sage, to check your work.
  8. Finally, let’s create and row-reduce a matrix. To create a matrix, type:
    M = matrix([[-3,-8,-22],[1,3,9]])

    (This is one of the matrices from the WebWork homework.) Notice that the syntax is very similar to WebWork. Also note that here we use a single equal sign.To see M, type:
    M
    and push shift-return.To row-reduce the matrix, type:
    M.rref()

  9. That’s it for the first week. Print out your worksheet (using the printer icon) and hand it in to me, with your name, for a few bonus points.
This entry was posted in Uncategorized. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.

Skip to toolbar