You are about to erase your work on this activity. Are you sure you want to do this?
Updated Version Available
There is an updated version of this activity. If you update to the most recent version of this activity, then your current progress on this activity will be erased. Regardless, your record of completion will remain. How would you like to proceed?
Mathematical Expression Editor
SageMath is a computer algebra system which uses python, throughout these labs
sage cells will be used for certain problems. This lab introduces you to the basics of
using SageMath via Sage Cells.
Introduction
If you ever want to use a sage cell when one is not provided, or would like to
experiment with Sage Cells, you can follow this link.
Functions
To define a function you use the notation in the following sage cell:
What output did you get from evaluating the sage cell?
None
All we did was define a function, to see the function definition type f(x).
Evaluate the function at by typing f(3) in the sage cell, what did you get?
Define in the following cell evaluate at
In sage, you type pi for and remember to
use the carrot for powers and * for multiplication!
What did you get?
If you don’t use function notation, or want to define a function of multiple variables
you must define your variables before using them, as in the following Sage
Cell. The following sage cell defines the equation , and then solves it for .
From the sage cell above, what can you say about ‘‘=’’ vs ‘‘==’’?
‘‘=’’ is used for
assignment and ‘‘==’’ is used to signify equality‘‘=’’ is used to signify equality
and ‘‘==’’ is used for assignment
Note that you need to include the * operator, go back and take out the * to see how
Sage Does error messages and debugging.
The solve command is also shown above, it’s fairly intuitive to use, the thing you
want to solve is the first parameter and what you’re solving for is the second
parameter.
Using the solve command, find the roots for
You should be solving for
Copy paste what you got in your sage cell here:
Getting Help
If you ever get stuck trying to use a command, there is built in documentation (as
well as Google). Type the command followed directly by ‘‘?’’ to get extensive
documentation on how to use it with examples. Try this for the solve command in
the following cell.