Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Math 208 Interactive Notebooks © 2024 by Soham Bhosale, Sara Billey, Herman Chau, Zihan Chen, Isaac Hartin Pasco, Jennifer Huang, Snigdha Mahankali, Clare Minerath, and Anna Willis is licensed under CC BY-ND 4.0
License: OTHER
Image: ubuntu2204
Isaac Hartin Pasco
Preamble: How to very basically use this. Cells are things you can type in and can be run. To run a cell you click on it with the left mouse button and then press shift and enter at the same time. In between Cells you should have a tooltip that appears if you hover your mouse there that says "Code Text Paste Generate". Code lets you type sage/python code and you run shift and enter to run it. Text lets you form a text box like this one that you can type and Markdown in pressing shift and enter in a text box formats it so it looks nice. Don't worry about the paste or generate boxes I don't know what they do. If you want to undo something control+z appears to do that. if you want to delete a cell go to edit in the top left next to file and go to delete cell. If you want to edit a cell you can double click it with the left mouse button.
A note about variables in python specifically, NOT ABOUT VARIABLES IN THE EQUATION STUFF. A variable in python is a box that contains something. you tell python what kind of something you want you want to have a variable to hold using . but without the quotes. You can set a variable to be the result of a mathematical expression for example or you use to add to subtract to divide to multiply and ^ to take something to a power. Note that this works with things that aren't numbers and depending on what they are, for example would make x be "hi there". you can also declare variables in terms of other variables and mathematical expressions with other variables assuming those variables already exist. Mathematical expressions obey order of operations and you can use parenthesis in them. One final thing. Code cells are evaluated from top to bottom and its a bad idea to do more than one equals sign per line. (the signifies two things actually being equal and you can have multiple of those just fine).
Alright. Finally we can get to linear equations. A linear equation is an equation that can be represented in the form s0x0+s1x1+s2x2+...+snxn=ys0x0+s1x1+s2x2+...+snxn=y where each of x0...xnx0...xn is a variable and each of s0...sns0...sn and yy is a scalar. these are very cool and useful for a lot of reasons that can be gotten into later. sage math and computer things make it so you can manipulate and solve them without having to brute force things and allows for generalizations and optimizations in the process of doing algebra that can be very useful. The sage documentation on linear algebra https://doc.sagemath.org/html/en/tutorial/tour_linalg.html is an excellent resource on this sort of thing.
note that the variables can be named almost anything they don't have to be named or . Just make sure they are letters and numbers and don't start with numbers e.g is a valid variable name and is a valid variable name but is not and neither is . They have to be ascii i think.
The equation can be written in normal equation writing like you would type it up, but you use ** instead of power and a instead of the normal equals signs because those are used to assign stuff to variables. also it doesn't multiply automatically if you put two things together if you want to multiply something you must put * between the two things or else it won't work. The equations also obey PEMDAS if you were curious
Equations and variables use the same naming conventions, anything that can be a valid variable name can be a valid equation name
For plotting the first value is an expression that either produces the y value on the graph or the z value of the graph depending on whether it is 3d, and the second and potential third parts tell them what values to evaluate the variables under. For example tells python to evaluate the value of x from -10 to 10
Systems of equations obey the same naming conventions as everything else. Please do not name things the same name as other things it will make your life very hard.
you can represent a system of linear equations by putting the coefficients of the linear equations into a matrix. this makes it so you can do things to that system of equations without having to worry about the original equations and allow you to treat that system as an object you can do math on,
although the above is a perfectly valid way of creating a matrix for reasons of convention the rest of this will use a different method of writing the columns of a matrix and then using .transpose to get the matrix right because that is a bit easier to work with
There are various operations you can do on matrices, but the fundamental ones you might want to use in solving a linear equation are swapping the postions of two rows, multiply a row by something that isn't zero and add a nonzero multiple of a row to another row
Matrices can also be added and subtracted etc but that is more complicated so don't worry about it for now
You do need to know about python stuff though so one last thing. Python Functions are a way of doing a bunch of extremely cool things. Don't put them into the linear equations we talked about above because they sort of break them but otherwise they are very useful. they work like functions in math in that you can use them with some arguments and depending on the function you get something back out. they can also work as subroutines where your code goes off and does something for a second, and then goes back to what it was doing before. they also might be both.
Note that unlike other things in a python file functions are not run unless called and if they are called they are run at the point where they are called. they are also effectively replaced with whatever they return so y = f(2) is equivalent to y = "2" in the above case although nothing would be printed out from f() if it was just y = "2"
and are also valid things for a variable to be and you can do things with them or get values of or from other expressions. For example evaluates to and evaluates to . putting in front of something changes it to the opposite of whatever it was if it's a boolean value. is for example. You can concatenate boolean(things that are either or ) expressions together to get more complicated logic
If you want something to only run if some particular thing is true you can use if to do that. if you follow and if with an "elif" if the first if expression sn't true the "elif" will evalute if the second expression is true. an else will execute if the if preceding it doesn't execute. Note you can chain elifs.