Page 50

In [1]:
var('a,b')
#  We declare to the program that symbols 'a' and 'b' are variables.

(3*a*(2*b+4)+3*b*(2*a+5)).expand() # Multiplication has to be written explicitly.
Out[1]:
12*a*b + 12*a + 15*b
In [1]:
var('a,b')
#  We declare to the program that symbols 'a' and 'b' are variables.

show((3*a*(2*b+4)+3*b*(2*a+5)).expand()) # Better notation
Out[1]:

Page 56

In [3]:
show((6661029375).factor())
Out[3]:

Page 59

In [4]:
gcd(gcd(135,2520),300)
Out[4]:
15
In [5]:
lcm(lcm(135,2520),300)
Out[5]:
37800

Page 123

In [6]:
var('m,n,k')
show(((6*m^3*n^3*k+4*m^2*n^4)/(2*m^3*n^3)).simplify_full())
Out[6]:

Page 154

In [7]:
solve((1+2*(4-x))/2-(2-x)/3==(6-2*x)/4+5/2,x)  # The sign for equality in the equation is written as ==!
Out[7]:
[x == -1]

Page 161

In [8]:
var('R,R1,R2')
show(solve(1/R==1/R1+1/R2,R2))
Out[8]:

Page 170

In [9]:
var('y')
solve([-3*x+5*y==8,x+7*y==6],x,y)
Out[9]:
[[x == -1, y == 1]]

Page 171

In [10]:
var('s1,s2,t,v1,v2,d')
show(solve([s1==v1*t,s2==v2*t,d==s1+s2],s1,s2,t))
Out[10]:

Page 222

In [11]:
Rational(0.25), (2/3).n(), Rational(2/3.n()), (Rational(0.25)).n()
Out[11]:
(1/4, 0.666666666666667, 2/3, 0.250000000000000)

Page 260

In [12]:
print(pi.n())  # We calculate number pi to SageMath default precision.
print(pi.n(digits = 50)) # We calculate number pi to 50 significant digits.
print(round(pi,5))  # We round number pi to the fifth decimal.
3.14159265358979
3.1415926535897932384626433832795028841971693993751
3.14159

Page 281

In [13]:
var('t')
plot(10*t-5*t^2,(t,0,3), ymin = 0, aspect_ratio=1)
# First input in the command is the function we are plotting, 
# second input tells us the interval on which we plot it,
# the remaining two inputs are optional,
#- the first sets the lower limit to value plotting,
# since we are not interested in negative heights,
#- the second says that the same units are on both axes.
Out[13]:

Page283

In [1]:
plot(x^3-x,(x,-2,2),ymin = -2, ymax=2, aspect_ratio = 1)
Out[1]:

Page 284

In [14]:
var('y')
implicit_plot(x^2+y^2==1, (x,-2,2),(y,-2,2), aspect_ratio = 1, axes = true,frame = false)
# The first two inputs tell the software which equation we are plotting
# and in which area of the plane.
# Other inputs are optional – the last two define
# that we will get a coordinate system with axes and not frames,
# which is default for the command implicit_plot.
Out[14]:

Page 285

In [17]:
var('y')
implicit_plot((x^2+y^2)^2==4*(x^2-y^2), (x,-2.5,2.5),(y,-1,1), aspect_ratio = 1,   gridlines = 'minor')+implicit_plot(x^2+y^2==1, (x,-2.5,2.5),(y,-1,1), axes = true,frame = false, color = 'red')
Out[17]: