Number Set Arithmetic and Precision
Understand integer, rational, and real arithmetic systems, floating‑point precision challenges, and how to handle significant digits and uncertainty propagation.
Summary
Read Summary
Flashcards
Save Flashcards
Quiz
Take Quiz
Quick Practice
Why is integer division considered not closed?
1 of 22
Summary
Types of Arithmetic Systems
Introduction
When we perform calculations, different number systems behave in different ways. Some arithmetic operations that work perfectly with whole numbers fail with fractions, and some operations that work with fractions become problematic when computers represent numbers with limited precision. Understanding these distinctions is essential because it explains why calculations sometimes produce unexpected results and how to account for errors in real-world computation.
Integer Arithmetic
Integers are whole numbers like −3, 0, 5, and 42. While integer arithmetic feels intuitive, it has an important limitation: it is not closed under division. This means dividing one integer by another doesn't always produce an integer.
For example, $7 \div 2 = 3.5$, which is not an integer. When a programming language performs "integer division," it typically truncates (cuts off) the decimal part, so $7 \div 2$ would yield just $3$. This behavior differs from the division you might perform with a calculator.
Rational Number Arithmetic
A rational number is any number that can be expressed as a fraction $\frac{a}{b}$ where $a$ and $b$ are integers and $b \neq 0$. Rational arithmetic is where fractions become important.
Adding and Subtracting Fractions
When fractions share the same denominator, addition is straightforward:
$$\frac{a}{c} + \frac{b}{c} = \frac{a+b}{c}$$
For example, $\frac{1}{4} + \frac{3}{4} = \frac{4}{4} = 1$.
When denominators differ, you must first find a common denominator. Multiplying the first fraction by $\frac{d}{d}$ and the second by $\frac{c}{c}$ produces:
$$\frac{a}{c} + \frac{b}{d} = \frac{ad}{cd} + \frac{bc}{cd} = \frac{ad + bc}{cd}$$
For example, $\frac{1}{2} + \frac{1}{3} = \frac{3}{6} + \frac{2}{6} = \frac{5}{6}$.
Subtraction follows the same pattern with a minus sign between numerators: $\frac{a}{c} - \frac{b}{d} = \frac{ad - bc}{cd}$.
Multiplying and Dividing Fractions
Multiplication is simpler than addition: multiply the numerators together and the denominators together:
$$\frac{a}{b} \times \frac{c}{d} = \frac{ac}{bd}$$
Division is performed by multiplying by the reciprocal (flipping the second fraction):
$$\frac{a}{b} \div \frac{c}{d} = \frac{a}{b} \times \frac{d}{c} = \frac{ad}{bc}$$
Closure Under Operations
A key property of rational arithmetic is that it is closed under addition, subtraction, multiplication, and division (except division by zero). This means performing any of these operations on two rational numbers always produces another rational number. For instance, $\frac{1}{2} + \frac{1}{3} = \frac{5}{6}$ is still rational.
Decimal Representations of Fractions
Every rational number can be expressed as a decimal. Decimal fractions have denominators that are powers of 10:
$$0.75 = \frac{75}{100} = \frac{3}{4}$$
Some rational numbers produce repeating decimals, where a sequence of digits repeats infinitely:
$$0.\overline{3} = 0.333... = \frac{1}{3}$$
The bar over the 3 indicates that the digit repeats. Similarly, $0.\overline{142857} = \frac{1}{7}$.
Real Number Arithmetic
Real numbers include all rational numbers plus irrational numbers like $\pi$ and $\sqrt{2}$, which cannot be expressed as fractions. Real number arithmetic introduces new challenges, particularly around precision.
Truncation and Rounding
When working with decimals, we often cannot keep all digits. Two common approaches are:
Truncation discards all digits beyond a chosen position. For example, $\pi = 3.14159...$ truncated to three decimal places is $3.141$.
Rounding adjusts the last retained digit based on what comes next. If the first discarded digit is 5 or greater, round up; otherwise, round down. The same value of $\pi$ rounded to three decimal places is $3.142$ (since the next digit, 1, causes us to round the final 1 up to 2).
Floating-Point Representation
Computers cannot store real numbers with infinite precision. Instead, they use floating-point representation, which expresses numbers in the form:
$$\text{significand} \times \text{base}^{\text{exponent}}$$
For example, $1,250 = 1.25 \times 10^3$ in decimal floating-point, or $12 = 1.5 \times 2^3$ in binary floating-point. The number of bits allocated to store the significand and exponent determines the precision and range of representable numbers.
Rounding Errors
A critical limitation of floating-point arithmetic is that rounding errors occur whenever a result requires more bits than are available. The computed value is rounded to the nearest representable number, introducing error. These errors are small individually but can accumulate when many operations are performed.
Approximation, Errors, and Significant Digits
Scientific and engineering work relies on measurements that are inherently inexact. Managing these uncertainties is crucial for reporting results responsibly.
What Are Significant Digits?
Significant digits are the digits in a number that represent its precision and certainty. In a measurement, they indicate the resolution of the instrument and the confidence in the result.
Zeros can be tricky:
Leading zeros (like the 0 in 0.025) are never significant; they only indicate position.
Trailing zeros without a decimal point (like the zeros in 1,200) are generally not significant.
Trailing zeros after a decimal point (like the zeros in 1.200) are always significant.
Zeros between non-zero digits are always significant.
For example:
$0.00456$ has 3 significant digits (4, 5, and 6)
$1.05$ has 3 significant digits (1, 0, and 5)
$3,000$ has 1 significant digit (3), but $3,000.0$ has 5 significant digits
Propagation of Uncertainty
When combining measurements through arithmetic:
For addition and subtraction, add the absolute uncertainties. If you measure 15.2 cm (±0.1 cm) plus 8.7 cm (±0.1 cm), the uncertainty of the sum is ±0.2 cm.
For multiplication and division, add the relative uncertainties (percentage uncertainties). If one value is known to within 2% and another to within 3%, the product is known to within 5%.
A practical shortcut: round your final answer to match the least precise input.
Scientific Notation and Significant Digits
Normalized scientific notation expresses a number as:
$$s \times 10^n$$
where $1 \le s < 10$ and $n$ is an integer. The significand $s$ contains all significant digits.
In scientific notation, every digit displayed in the significand is significant. For instance, $1.25 \times 10^3$ has 3 significant digits, while $1.250 \times 10^3$ has 4 significant digits.
<extrainfo>
Exponentiation and Logarithms in Real Arithmetic
For positive bases, exponentiation (raising a number to a power) is closed in the real numbers. Logarithms, the inverse operation, are defined only for positive arguments and bases not equal to 1. These properties ensure that certain operations always produce valid results within the real number system.
Exponentiation by Squaring
When computing large powers, naive repeated multiplication is inefficient. Exponentiation by squaring accelerates this process by using the fact that $x^{2n} = (x^n)^2$ and $x^{2n+1} = x \cdot x^{2n}$. This reduces the number of multiplications needed from O(n) to O(log n).
</extrainfo>
Floating-Point Arithmetic in Practice
Non-Associativity of Addition
One of the most surprising properties of floating-point arithmetic is that addition is not associative. In exact arithmetic, $(a + b) + c = a + (b + c)$ always holds. But with rounding errors:
$$(a + b) + c \neq a + (b + c)$$
This occurs because rounding happens after each operation. Adding a very large number and a very small number can result in the small number being "lost" to rounding, and the order in which you combine numbers affects whether this happens.
<extrainfo>
IEEE 754 Standard
The IEEE 754 standard (published by the Institute of Electrical and Electronics Engineers) defines how computers represent and perform floating-point arithmetic. It specifies formats (like 32-bit and 64-bit), how rounding is done, how special values (like infinity and "not a number") are handled, and how errors should be reported. This standardization ensures that floating-point arithmetic behaves consistently across different computers.
Arbitrary-Precision Arithmetic
When speed is not a constraint, arbitrary-precision arithmetic can be used, where precision is limited only by available computer memory rather than a fixed number of bits. This is valuable for applications requiring extremely accurate results, such as cryptography or mathematical research. Languages and libraries like Python and GMP (GNU Multiple Precision) support this.
</extrainfo>
Flashcards
Why is integer division considered not closed?
Because dividing one integer by another can yield a non-integer result (e.g., $7 \div 2 = 3.5$).
What technique can be used to accelerate exponentiation by repeated multiplication?
Exponentiation by squaring.
How are fractions with a common denominator added?
By adding the numerators: $\frac{a}{c} + \frac{b}{c} = \frac{a+b}{c}$.
How do you find a common denominator to add fractions with different denominators?
By scaling the fractions: $\frac{a}{c} + \frac{b}{d} = \frac{ad+bc}{cd}$.
What is the rule for multiplying two rational numbers?
Multiply the numerators and denominators separately: $\frac{a}{b} \times \frac{c}{d} = \frac{ac}{bd}$.
How is division performed between two rational numbers?
By multiplying the first fraction by the reciprocal of the second: $\frac{a}{b} \div \frac{c}{d} = \frac{a}{b} \times \frac{d}{c} = \frac{ad}{bc}$.
Under which operations is rational arithmetic closed (excluding division by zero)?
Addition
Subtraction
Multiplication
Division
What defines a decimal fraction in terms of rational numbers?
It is a rational number with a denominator that is a power of 10 (e.g., $0.75 = \frac{75}{100}$).
What type of numbers are represented by repeating decimals?
Rational numbers (e.g., $0.\overline{3} = \frac{1}{3}$).
Under what condition are logarithms defined for real numbers?
When the arguments and bases are positive, and the base is not equal to 1.
How does rounding differ from truncation when the first discarded digit is 5 or greater?
The last retained digit is adjusted upward.
Which three components represent a real number in floating-point arithmetic?
Significand
Base (usually 2)
Exponent
When do rounding errors occur in floating-point arithmetic?
When a result requires more bits than are available, forcing it to be rounded to the nearest representable number.
Which types of zeros are generally considered non-significant in measurements?
Leading zeros and trailing zeros without a decimal point.
How is the uncertainty of the result calculated when adding or subtracting quantities?
By summing the absolute uncertainties of the inputs.
How is the uncertainty of the result calculated when multiplying or dividing quantities?
By summing the relative (percentage) uncertainties.
What is a simple way to approximate the propagation of uncertainty in a final answer?
By rounding the answer to the least precise term among the inputs.
In normalized scientific notation ($s \times 10^{n}$), what is the restricted range for the significand $s$?
$1 \le s < 10$.
What is the effect of adding trailing zeros to the significand in scientific notation?
It increases the precision of the number.
Why is floating-point addition not associative?
Because rounding errors depend on the specific order in which operations are performed.
What is the purpose of the IEEE 754 standard?
It defines representation, arithmetic operations, rounding, and error handling for binary floating-point numbers.
What is the primary limiting factor for arbitrary-precision arithmetic?
The computer's available memory.
Quiz
Number Set Arithmetic and Precision Quiz Question 1: Which technique speeds up exponentiation compared with repeated multiplication?
- Exponentiation by squaring (correct)
- Long multiplication
- Division by repeated subtraction
- Binary search
Number Set Arithmetic and Precision Quiz Question 2: How do you compute $\frac{a}{b}\div\frac{c}{d}$?
- \frac{ad}{bc} (correct)
- \frac{ac}{bd}
- \frac{a+b}{c+d}
- \frac{a-b}{c-d}
Number Set Arithmetic and Precision Quiz Question 3: What name is given to rational numbers whose denominator is a power of 10?
- Decimal fractions (correct)
- Repeating decimals
- Irrational numbers
- Complex numbers
Number Set Arithmetic and Precision Quiz Question 4: For which values of the argument and base is the logarithm function defined in the real number system?
- Argument > 0 and base > 0 with base ≠ 1 (correct)
- Argument any real number and base any positive number
- Argument > 0 and base = 1
- Argument any real number and base any non‑zero number
Number Set Arithmetic and Precision Quiz Question 5: In normalized scientific notation, what interval must the significand $s$ obey?
- 1 ≤ $s$ < 10 (correct)
- 0 ≤ $s$ ≤ 1
- $s$ > 10
- $s$ = 0
Number Set Arithmetic and Precision Quiz Question 6: When arbitrary‑precision arithmetic is used without time constraints, what determines the maximum number of digits that can be represented?
- The amount of available memory. (correct)
- The clock speed of the CPU.
- The number of CPU cores.
- The size of the hard‑drive cache.
Number Set Arithmetic and Precision Quiz Question 7: Which arithmetic property of floating‑point addition fails because rounding errors depend on the order of operations?
- Associativity (correct)
- Commutativity
- Identity
- Distributivity
Which technique speeds up exponentiation compared with repeated multiplication?
1 of 7
Key Concepts
Number Types and Operations
Integer arithmetic
Rational number arithmetic
Real number arithmetic
Floating‑point arithmetic
Arbitrary‑precision arithmetic
Precision and Errors
Significant digits
Rounding error
Propagation of uncertainty
Advanced Arithmetic Techniques
Exponentiation by squaring
IEEE 754
Definitions
Integer arithmetic
Operations on whole numbers where division may produce non‑integer results, highlighting that the set is not closed under division.
Rational number arithmetic
Calculations with fractions, including addition, subtraction, multiplication, and division, which remain within the set of rational numbers.
Real number arithmetic
Operations on real numbers, encompassing exponentiation, logarithms, truncation, rounding, and the representation of numbers with infinite precision.
Floating‑point arithmetic
Approximate representation of real numbers using a fixed number of bits for a significand and exponent, subject to rounding errors and limited precision.
IEEE 754
The industry standard defining binary floating‑point formats, rounding rules, exception handling, and arithmetic operations for computers.
Arbitrary‑precision arithmetic
Computation with numbers whose precision is limited only by available memory, allowing exact results at the cost of speed.
Significant digits
The digits in a measurement that convey its precision, excluding leading zeros and non‑significant trailing zeros without a decimal point.
Rounding error
The discrepancy introduced when a number is approximated to the nearest representable value due to limited precision.
Exponentiation by squaring
An efficient algorithm for raising a number to an integer power by repeatedly squaring, reducing the number of multiplications needed.
Propagation of uncertainty
The method of estimating the uncertainty in a result based on the uncertainties of the input quantities, using absolute or relative rules.