Book contents
- Frontmatter
- Contents
- Preface
- Part one Foundations
- Part two Investigations
- 8 Magic Squares
- 9 GCDs, Pseudoprimes and Miller's Test
- 10 Graphics: Curves and Envelopes
- 11 Zigzags and Fast Curves
- 12 Sequences of Real Numbers
- 13 Newton–Raphson Iteration and Fractals
- 14 Permutations
- 15 Iterations for Nonlinear Equations
- 16 Matrices and Solution of Linear Systems
- 17 Function Interpolations and Approximation
- 18 Ordinary Differential Equations
- Part three Modelling
- Appendix 1 MATLAB Command Summary
- Appendix 2 Symbolic Calculations within MATLAB
- Appendix 3 List of All M-files Supplied
- Appendix 4 How to Get Solution M-files
- Appendix 5 Selected MATLAB Resources on the Internet
- References
- Index
9 - GCDs, Pseudoprimes and Miller's Test
Published online by Cambridge University Press: 08 February 2010
- Frontmatter
- Contents
- Preface
- Part one Foundations
- Part two Investigations
- 8 Magic Squares
- 9 GCDs, Pseudoprimes and Miller's Test
- 10 Graphics: Curves and Envelopes
- 11 Zigzags and Fast Curves
- 12 Sequences of Real Numbers
- 13 Newton–Raphson Iteration and Fractals
- 14 Permutations
- 15 Iterations for Nonlinear Equations
- 16 Matrices and Solution of Linear Systems
- 17 Function Interpolations and Approximation
- 18 Ordinary Differential Equations
- Part three Modelling
- Appendix 1 MATLAB Command Summary
- Appendix 2 Symbolic Calculations within MATLAB
- Appendix 3 List of All M-files Supplied
- Appendix 4 How to Get Solution M-files
- Appendix 5 Selected MATLAB Resources on the Internet
- References
- Index
Summary
This chapter contains two investigations of a number-theoretic nature, building on the ideas of Chapter 3. Investigation A is on greatest common divisors (gcds), and B is on pseudoprimes and Miller's test for primality.
A GCDs of random pairs and triples of numbers
Aims of the project
The idea is to find, by theoretical and experimental means, estimates for the probability that a pair of randomly chosen positive integers have no common factor. This is also extended to triples of numbers.
Mathematical ideas used
Elementary ideas of probability are used (e.g., probability of two independent events is the product of their individual probabilities). There are several mathematical arguments given which need to be ‘filled in’ with some details—in fact, this project is more mathematical than computational. The idea is to use mathematical arguments and experiment to determine certain probabilities, such as: given three random integers, what is the probability that each of the three resulting pairs of integers are coprime—that is, have gcd 1?
MATLAB techniques used
The project uses the M-flle gcdiv.m from Chapter 3, which calculates the gcd of two integers. It also requires the writing of some M-files which use loops and conditionals.
The M-flle gcdran.m takes n pairs of ‘random’ numbers, each < 1000, and finds the gcd of each pair, then prints out the percentage of pairs with gcd equal to 1.
- Type
- Chapter
- Information
- Mathematical Explorations with MATLAB , pp. 108 - 115Publisher: Cambridge University PressPrint publication year: 1999