Numbers And Arithmetic
On this page
Algebra is a generalization of arithmetic: instead of only working with fixed numbers, it introduces variables and rules for manipulating expressions that contain them. Before you can manipulate expressions, you need to be fluent with the objects inside them, which are numbers and the operations on numbers. This note covers the number systems, fractions, powers, roots, rational exponents and radicals. Solving equations builds on all of this and lives in "Equations".
Anatomy Of An Algebraic Expression
An algebraic expression mixes numbers, letters and operations. Each letter has a specific role, and knowing the role tells you what you are allowed to change while solving a problem.
| Part | In the example | Role |
|---|---|---|
| Coefficient | and | Number multiplying a variable term |
| Variable | Can take any value, this is what we usually solve for | |
| Exponent (power) | How many times is multiplied by itself | |
| Parameter | Treated as fixed for one particular problem, but can change between problems | |
| Constant | Never changes |
The difference between a parameter and a variable is a matter of perspective. Think of a function in code with a default argument: inside one call, the argument is fixed (parameter), but the function body is written for any input (variable). Once you know and , the expression gives a result for every value of .
Number Systems
Numbers need a representation for the human mind, and we generally use the decimal system (base 10). As a computer scientist you also know binary (base 2), octal (base 8) and hexadecimal (base 16). The representation changes, the number itself does not: 0b1010, 0xA and 10 are the same value.
Mathematics uses several classes of numbers. Each class extends the previous one so that more problems can be solved.
The Five Sets
| Set | Symbol | Contains | Examples | Typical use |
|---|---|---|---|---|
| Natural numbers | Counting numbers | Counting, indexing arrays and lists | ||
| Integers | Naturals plus negatives | Gains and losses, signed coordinates | ||
| Rational numbers | Fractions with , | Ratios, exact decimal values | ||
| Real numbers | Rationals plus irrationals | Every point on the number line, calculus, ML | ||
| Complex numbers | with and | Signal processing, graphics, control theory |
The sets form a strict hierarchy:
Every set contains all the elements of the previous one, so is a natural number, but also an integer, a rational (), a real and a complex number (). When you classify a number, you name the smallest set it belongs to.
How To Recognise Each Kind
A rational number always has a decimal expansion that either terminates (, ) or repeats (). An irrational number has a decimal expansion that never stops and never repeats, which is exactly why it cannot be written as a fraction of two integers. Some irrationals, such as and , are so special that they are called transcendental: they are not the root of any polynomial equation with integer coefficients.
Why Bigger Sets Exist
The need for a larger number system usually comes from an equation that has no solution in the current one. Each step up the ladder below is forced by an equation.
The pattern is that every inverse operation eventually breaks out of its set: subtraction breaks , division breaks , square roots break , and square roots of negatives break .
Proving √2 Is Irrational
This classic proof shows the technique of proof by contradiction: assume the opposite of what you want, and show that it leads to something impossible.
- Assume is rational, so with , , and the fraction in lowest terms, meaning .
- Square both sides: , so . That means is even.
- The square of an odd number is odd, so itself must be even. Write .
- Substitute: . So is even, and therefore is even.
- Now both and are even, so divides both. That contradicts .
The assumption was false, so is irrational. The same proof works for with any prime : replace "even" with "divisible by " and use the fact that if a prime divides , it divides .
Fractions
A fraction represents a part of a whole, or more generally the division of by . The top number is the numerator, the bottom number is the denominator, and the denominator must never be .
Simplifying
A fraction is simplified (in lowest terms) when the numerator and denominator have no common divisor other than . Divide both by their greatest common divisor:
This works because dividing top and bottom by the same number is the same as dividing the fraction by , which does not change its value.
Adding And Subtracting
You can only add fractions that describe pieces of the same size, so the denominators must match first. If they differ, rewrite both fractions over a common denominator:
Subtraction works exactly the same way.
Multiplying
Multiplying is simpler, because no common denominator is needed. Multiply the numerators together and the denominators together, then simplify:
Dividing: Keep, Change, Flip
To divide by a fraction, multiply by its reciprocal. The reciprocal of is .
The memory rule is keep, change, flip: keep the first fraction, change into , flip the second fraction.
Why does flipping work? Dividing by a number asks "how many of these fit in?". Asking how many quarters fit into one half is the same as multiplying by , because each whole holds four quarters: .
Common Mistakes With Fractions
| Mistake | Wrong | Right |
|---|---|---|
| Dividing top and bottom separately | ||
| Flipping the first fraction | ||
| Forgetting to simplify | ||
| Dividing by zero | Undefined: has no reciprocal |
A useful sanity check: dividing a positive number by a fraction smaller than always makes it bigger. If your answer shrank, something went wrong.
Powers
Powers are shorthand for repeated multiplication. Instead of writing , you write .
Here is the base and is the exponent (or power). is called the square of and the cube.
Zero And Negative Exponents
Two definitions extend powers beyond positive whole exponents, and both follow from the division rule below. Since and also , it must be that:
And since , a negative exponent means a reciprocal:
The Three Rules
All three rules come straight from counting factors. is factors followed by more factors, so factors in total.
| Rule | Formula | Example |
|---|---|---|
| Product (same base) | ||
| Quotient (same base) | , | |
| Power of a power |
In computer science you meet powers constantly: a byte holds values, an IPv4 address space has addresses, and bytes.
Common Mistakes With Powers
The order of operations matters a lot with powers, because the exponent binds tighter than a minus sign.
| Mistake | Wrong | Right |
|---|---|---|
| Power is not multiplication | ||
| Adding powers is not adding exponents | ||
| Minus sign outside the power | , but | |
| Anything to the power zero |
The same trap exists in code. In Python, -2**2 evaluates to -4 because ** binds tighter than unary minus.
print(-2**2) # -4
print((-2)**2) # 4
print(2**3 + 2**3 == 2**6) # False: 16 vs 64Roots
Roots are the inverse operation of powers. Just as division undoes multiplication, taking a root undoes raising to a power.
Square Roots
The square root is the non-negative number whose square equals . So because . Squaring and square rooting undo each other:
The condition matters. For negative , , not . The fully general rule is , the absolute value.
A perfect square is an integer that is the square of another integer: Their roots are whole numbers. Every other positive integer has an irrational square root, such as and .
Higher Roots
The cube root undoes a cube: because , and . In general is the number that gives when raised to the power . Unlike square roots, odd roots of negative numbers are fine in : .
Common Mistakes With Roots
The square root of a negative number does not exist in , only in . The biggest mistake, though, is splitting a root over a sum:
Roots split over multiplication and division, never over addition or subtraction. The same is true for powers: .
Rational Exponents
Exponents can also be fractions. A rational exponent is just another notation for a root, and the big advantage is that all the power rules keep working.
Why is ? Apply the product rule: . A number that multiplied by itself gives is exactly the definition of .
Reading m/n
The denominator is the root, the numerator is the power. A good way to remember it: the denominator is "down at the root".
Common Mistakes With Rational Exponents
Swapping the numerator and denominator is the classic error: is the cube root squared, not the square root cubed (). The second tip is about order: mathematically both orders give the same result, but taking the root first keeps the numbers small. Computing as is much harder by hand than .
Radicals
The symbol is the radical sign, and any expression with roots is a radical. In , is the index and is the radicand. For square roots the index is left out.
Simplifying Radicals
Look for a perfect square factor inside the radicand, split it off and take its root. This uses the rule .
Always pick the largest perfect square factor. For , using gives which is not finished, while using gives directly.
Multiplying And Dividing Radicals
Radicals with the same index can be combined under one radical sign:
Adding And Subtracting Radicals
Radicals behave like variables here: you can only add like terms, meaning the same radical part. Think of as a unit, just like in .
Often the radicals only become like terms after simplifying them, so always simplify first:
Worked Exercises
These are representative exercises from the course book, with the reasoning written out. Try them yourself first, then compare.
Classify Numbers
Name the smallest set for , , and . The answers are , , and . For , since is prime, the generalised proof says it is irrational, so .
Fractions In Context
A recipe needs cup of flour and you make half the recipe. "Half of" means multiply by : cup.
Spot the error in . The fractions were multiplied instead of divided. Keep, change, flip gives .
Converting decimals: and .
Powers And Roots
is true, is false (), is true and is false ().
and .
Radicals
.
, and .
Quick Recap
- Expression parts: coefficients multiply, variables vary, parameters are fixed per problem, constants never change.
- Number sets: . Each one exists because some equation has no solution in the smaller set. Classify by the smallest set.
- Rational vs irrational: rational decimals stop or repeat, irrational decimals do neither. is irrational for every prime (proof by contradiction).
- Fractions: common denominator for and , straight across for , keep change flip for . Never divide by .
- Powers: , , , , . Watch .
- Roots: inverse of powers, . Roots split over and , never over or .
- Rational exponents: , denominator is the root, numerator the power. Take the root first.
- Radicals: pull out the largest perfect square, then add only like radicals.