Introduction to Pure Mathematics with CoCalc

Getting Started with Mathematical Computing

Welcome to Mathematical Discovery

Pure mathematics—the exploration of mathematical concepts for their own beauty and elegance—has never been more accessible. CoCalc provides a comprehensive environment where you can explore algebra, number theory, geometry, and analysis without the barriers of complex software installation or expensive licenses.

For detailed information about SageMath and mathematical computing features, see the CoCalc SageMath documentation.

Whether you're a student encountering abstract mathematics for the first time, a researcher exploring new mathematical territories, or simply someone fascinated by the beauty of mathematical truth, CoCalc offers the tools you need to transform abstract concepts into concrete understanding.

Your Mathematical Toolkit

SageMath: Your Mathematical Companion

SageMath is your primary tool for mathematical exploration—a comprehensive system that combines the power of dozens of specialized mathematical packages into one unified interface.

Note: Use a SageMath kernel/worksheet for these examples, not Python.

# Welcome to mathematical computing!
# Let's start with basic symbolic mathematics

# Working with symbolic variables
x, y, z = var('x y z')

# Symbolic expressions and algebra
expr = (x + 1)^3
expanded = expand(expr)
factored = factor(x^3 + 3*x^2 + 3*x + 1)

print("Original expression:", expr)
print("Expanded form:", expanded)
print("Factored form:", factored)

# Basic calculus
f = x^2 + 3*x + 2
derivative = diff(f, x)
integral = integrate(f, x)

print("\nFunction: f(x) =", f)
print("Derivative: f'(x) =", derivative)
print("Integral: ∫f(x)dx =", integral)

Output:

Original expression: (x + 1)^3
Expanded form: x^3 + 3*x^2 + 3*x + 1
Factored form: (x + 1)^3
Function: f(x) = x^2 + 3*x + 2
Derivative: f'(x) = 2*x + 3
Integral: ∫f(x)dx = 1/3*x^3 + 3/2*x^2 + 2*x

Exploring Number Theory

Number theory—the study of integers and their properties—comes alive with computational exploration:

# Number theory explorations
print("=== NUMBER THEORY ADVENTURES ===")

# Prime numbers and factorization
n = 2023
print("\nIs", n, "prime?", is_prime(n))
print("Prime factorization of", n, ":", factor(n))

# Finding primes
primes_up_to_100 = [p for p in range(2, 101) if is_prime(p)]
print("\nFirst few primes:", primes_up_to_100[:10])
print("Number of primes up to 100:", len(primes_up_to_100))

# The Euclidean algorithm
a, b = 48, 18
gcd_result = gcd(a, b)
print("\ngcd(", a, ",", b, ") =", gcd_result)

# Extended Euclidean algorithm
g, u, v = xgcd(a, b)
print("Extended:", u, "·", a, " + ", v, "·", b, " = ", g)

Output:

=== NUMBER THEORY ADVENTURES ===

Is 2023 prime? False
Prime factorization of 2023 : 7 * 17^2

First few primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
Number of primes up to 100: 25

gcd( 48 , 18 ) = 6
Extended: -1 · 48 + 3 · 18 = 6

Algebraic Structures

Explore the fundamental structures that underlie mathematics:

# Group theory basics
print("=== ALGEBRAIC STRUCTURES ===")

# Modular arithmetic
print("\nModular arithmetic:")
for i in range(12):
print(i, "mod 5 =", i % 5)

# Working with permutations
# Create a simple permutation group
S3 = SymmetricGroup(3)
print("\nSymmetric group S3 has order:", S3.order())
print("Elements of S3:", list(S3))

# Group operations
g1 = S3([2, 1, 3]) # Swap first two elements
g2 = S3([1, 3, 2]) # Swap last two elements
product = g1 * g2
print("\nPermutation multiplication:")
print(g1, "*", g2, "=", product)

Output:

=== ALGEBRAIC STRUCTURES ===

Modular arithmetic:
0 mod 5 = 0
1 mod 5 = 1
2 mod 5 = 2
3 mod 5 = 3
4 mod 5 = 4
5 mod 5 = 0
6 mod 5 = 1
7 mod 5 = 2
8 mod 5 = 3
9 mod 5 = 4
10 mod 5 = 0
11 mod 5 = 1

Symmetric group S3 has order: 6
Elements of S3: [(), (2,3), (1,2), (1,2,3), (1,3,2), (1,3)]

Permutation multiplication:
(1,2) * (2,3) = (1,2,3)

Calculus and Analysis

Move from discrete to continuous mathematics:

# Calculus explorations
print("=== CALCULUS AND ANALYSIS ===")

# Limits
x = var('x')
limit_expr = sin(x)/x
limit_result = limit(limit_expr, x=0)
print("lim(x→0) sin(x)/x =", limit_result)

# Series expansions
f = e^x
taylor_series = f.taylor(x, 0, 5) # Taylor series around x=0, degree 5
print("\nTaylor series of e^x:", taylor_series)

# Definite integrals
integral_result = integrate(x^2 * e^(-x^2), x, -oo, oo)
print("\n∫_{-∞}^{∞} x²e^(-x²) dx =", integral_result)

# Plotting functions
p1 = plot(sin(x), (x, -2*pi, 2*pi), color='blue', legend_label='sin(x)')
p2 = plot(cos(x), (x, -2*pi, 2*pi), color='red', legend_label='cos(x)')
combined_plot = p1 + p2
combined_plot.show()

Output:

=== CALCULUS AND ANALYSIS ===
lim(x→0) sin(x)/x = 1

Taylor series of e^x: 1/120*x^5 + 1/24*x^4 + 1/6*x^3 + 1/2*x^2 + x + 1

∫_{-∞}^{∞} x²e^(-x²) dx = 1/2*sqrt(pi)

Linear Algebra: The Language of Modern Mathematics

Linear algebra provides the foundation for understanding higher mathematics:

# Linear algebra basics
print("=== LINEAR ALGEBRA ===")

# Matrices and vectors
A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
v = vector([1, 2, 3])

print("Matrix A:")
print(A)
print("Vector v:", v)

# Matrix operations
det_A = A.determinant()
print("\nDeterminant of A:", det_A)

# Eigenvalues and eigenvectors
B = Matrix([[2, 1], [1, 2]])
eigenvals = B.eigenvalues()
eigenvects = B.eigenvectors_right()

print("\nMatrix B:")
print(B)
print("Eigenvalues:", eigenvals)
print("Eigenvectors:")
for eval, evect, mult in eigenvects:
print(" λ =", eval, ", v =", evect[0], ", multiplicity =", mult)

Output:

=== LINEAR ALGEBRA ===
Matrix A:
[1 2 3]
[4 5 6]
[7 8 9]
Vector v: (1, 2, 3)

Determinant of A: 0

Matrix B:
[2 1]
[1 2]
Eigenvalues: [3, 1]
Eigenvectors:
λ = 3 , v = (1, 1) , multiplicity = 1
λ = 1 , v = (1, -1) , multiplicity = 1

Mathematical Visualization

Mathematics becomes more intuitive when you can see it:

# 2D plotting
x = var('x')
p1 = plot(sin(x), (x, -2*pi, 2*pi), color='blue', legend_label='sin(x)')
p2 = plot(cos(x), (x, -2*pi, 2*pi), color='red', legend_label='cos(x)')

combined_plot = p1 + p2
combined_plot.axes_labels(['x', 'y'])
combined_plot.legend(True)
combined_plot.show(title='Trigonometric Functions')

# 3D surface
x, y = var('x y')
surface_plot = plot3d(x^2 + y^2, (x, -2, 2), (y, -2, 2))
surface_plot.show()

Getting Started: Your First Mathematical Explorations

Exercise 1: Number Theory Investigation

# Investigate perfect numbers
def is_perfect(n):
"""Check if n is a perfect number"""
divisors = [i for i in range(1, n) if n % i == 0]
return sum(divisors) == n

# Find perfect numbers up to 100
perfect_numbers = [n for n in range(1, 101) if is_perfect(n)]
print("Perfect numbers up to 100:", perfect_numbers)

# Investigate their properties
for p in perfect_numbers:
divisors = [i for i in range(1, p) if p % i == 0]
print(p, ": divisors =", divisors, ", sum =", sum(divisors))

Output:

Perfect numbers up to 100: [6, 28]
6 : divisors = [1, 2, 3] , sum = 6
28 : divisors = [1, 2, 4, 7, 14] , sum = 28

Exercise 2: Polynomial Exploration

# Explore polynomial behavior
x = var('x')
polynomials = [
x^2 - 1, # Quadratic
x^3 - 3*x + 1, # Cubic
x^4 - 5*x^2 + 6 # Quartic
]

for poly in polynomials:
print("\nPolynomial:", poly)

# Find roots
roots = solve(poly == 0, x)
print("Roots:", roots)

# Factor if possible
try:
factored = factor(poly)
print("Factored form:", factored)
except:
print("Cannot factor over rationals")

# Plot the polynomial
plot(poly, (x, -3, 3)).show()

Output:

Polynomial: x^2 - 1
Roots: [x == -1, x == 1]
Factored form: (x - 1)*(x + 1)

Polynomial: x^3 - 3*x + 1
Roots: [x == -1/2*sqrt(5) - 1/2, x == 1/2*sqrt(5) - 1/2, x == 1]
Factored form: x^3 - 3*x + 1

Polynomial: x^4 - 5*x^2 + 6
Roots: [x == -sqrt(3), x == sqrt(3), x == -sqrt(2), x == sqrt(2)]
Factored form: (x^2 - 3)*(x^2 - 2)

Exercise 3: Matrix Magic

# Explore special matrices
print("=== SPECIAL MATRICES ===")

# Identity matrix
I = identity_matrix(3)
print("Identity matrix:")
print(I)

# Rotation matrix (2D)
angle = pi/4 # 45 degrees
rotation_2d = Matrix([[cos(angle), -sin(angle)],
[sin(angle), cos(angle)]])
print("\n45° rotation matrix:")
print(rotation_2d)

# Apply rotation to a vector
v = vector([1, 0])
rotated_v = rotation_2d * v
print("Original vector:", v)
print("Rotated vector:", rotated_v)

# Verify the rotation preserves length
print("Original length:", v.norm())
print("Rotated length:", rotated_v.norm())

Output:

=== SPECIAL MATRICES ===
Identity matrix:
[1 0 0]
[0 1 0]
[0 0 1]

45° rotation matrix:
[1/2*sqrt(2) -1/2*sqrt(2)]
[1/2*sqrt(2) 1/2*sqrt(2)]

Original vector: (1, 0)
Rotated vector: (1/2*sqrt(2), 1/2*sqrt(2))
Original length: 1
Rotated length: 1

Building Mathematical Intuition

Understanding Through Computation

Mathematical intuition develops through active exploration. Use CoCalc to:

Test Conjectures: Try examples and look for patterns

Visualize Concepts: Plot functions and geometric objects

Verify Calculations: Check hand computations with symbolic math

Explore Edge Cases: See what happens at boundaries and special values

Example: The Fibonacci Sequence

# Fibonacci explorations
def fibonacci_sequence(n):
"""Generate first n Fibonacci numbers"""
fib = [1, 1]
for i in range(2, n):
fib.append(fib[i-1] + fib[i-2])
return fib

# Generate Fibonacci numbers
fib_nums = fibonacci_sequence(20)
print("First 20 Fibonacci numbers:", fib_nums)

# Investigate the golden ratio connection
golden_ratio = (1 + sqrt(5))/2
ratios = [fib_nums[i+1]/fib_nums[i] for i in range(len(fib_nums)-1)]

print("\nGolden ratio:", float(golden_ratio))
print("Consecutive Fibonacci ratios:")
for i, ratio in enumerate(ratios[-10:], len(ratios)-9):
print("F(", i+1, ")/F(", i, ") =", float(ratio))

# Plot convergence to golden ratio
data_points = [(i, float(ratios[i-1])) for i in range(1, len(ratios)+1)]
ratio_plot = list_plot(data_points, color='blue', plotjoined=True, legend_label='F(n+1)/F(n)')
ratio_plot += line([(1, float(golden_ratio)), (len(ratios), float(golden_ratio))], color='red', linestyle='--', legend_label='Golden Ratio')
ratio_plot.axes_labels(['n', 'Ratio'])
ratio_plot.title('Fibonacci Ratios Converging to Golden Ratio')
ratio_plot.show()

Next Steps in Your Mathematical Journey

Immediate Explorations

Prime Number Patterns: Investigate prime gaps and distributions

Geometric Sequences: Explore convergence and divergence

Function Transformations: See how parameters affect graphs

Matrix Powers: Discover patterns in repeated matrix multiplication

Preparing for Advanced Topics

Abstract Algebra: Group and ring theory

Real Analysis: Rigorous foundations of calculus

Complex Analysis: Functions of complex variables

Topology: Properties preserved under continuous deformations

Mathematical Research Skills

Conjecture Formation: Making educated mathematical guesses

Proof Techniques: Direct, indirect, and inductive reasoning

Mathematical Writing: Communicating ideas clearly

Collaboration: Working with others on mathematical problems

Resources for Continued Learning

Documentation and Help

SageMath Documentation: Comprehensive guides and examples

CoCalc Help: Platform-specific tutorials and tips

Mathematical Communities: Online forums and discussion groups

Practice Problems

Project Euler: Computational mathematics challenges

Mathematical Olympiad Problems: Contest mathematics

Research Papers: Current mathematical investigations

Pure mathematics in CoCalc opens doors to a universe of mathematical beauty and discovery. Start with simple explorations, build your computational skills, and gradually tackle more sophisticated problems. Every mathematician started with curiosity—let CoCalc help you transform that curiosity into deep mathematical understanding.

Begin your mathematical journey today. Access SageMath and start exploring at cocalc.com