Using Intermediate Variables

Description

We will be storing a constant in a variable for use in further calculations. This technique is notably useful when using Sage for various scientific calculations requiring use of constants. For this example we will be storing and using the fraction $59/43$ in the letter j.

Sage Cell

Code

j = 59/43
2 * j

Options

Option

We can also store a numerical approximation using the .n() method:

We can also change a variable into a numerical approximation:

Or display it as a numerical approximation without changing the variable:

Code

j = (59/43).n()
j
j = 59/43
j = j.n()
j
j = 59/43
j.n()

Tags

Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.

Attribute

Permalink:

Author: Gregory V. Bard. Sage for Undergraduates. American Mathematical Society, Providence, RI, 2015. Available at http://www.gregorybard.com/Sage.html.

Date: 19 Feb 2019 02:34

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License