# Lecture 4: Basic Arithmetic Algorithms

### Background Material and Further Resources

• Review Maple and C programming.

• Chap. 4 of the text.
• Handout: "Computer Algebra of Polynomials and Rational Functions"

### Topics

1. Go over assignment 3
2. Maple programs for computing the probability that two Gaussian integers are relatively prime and the average number of division steps in the Euclidean algorithm for Gaussian integers.
3. Introduction to the SACLIB computer algebra library (A library of C callable algorithms for computing with polynomials and related structures. See Using SACLIB for a brief introduction on how to use SACLIB.
4. Elementary data structures and algorithms in SACLIB.
1. list processing
2. representation of integers and polynomials
3. algorithms for basic arithmetic (DPR, DQR, IPROD, IQR, ISUM)
4. Computing time analysis of these functions.
5. Relating empirical computing times to theoretical computing times. E.G. Classical algorithm for integer multiplication.
• Obtaining empirical computing times for random inputs with varying sizes.
• Example timing program tiprod.c (time integer product routine IPROD). See Makefile to compile and link this programs.
• Ploting times as a function of input sizes and comparing (using limits) to theoretical computing times.
• Obtaining function to estimate computing time by fitting timing data to computing time function with unkown parameters.
• Maple worksheet illustrating these ideas using data from tiprod.
6. Computing time analysis of two methods for computing modular inverses in Z_m, where m is a beta digit (fits in a single word). See MDINV from the SACLIB library for an approach using the half-extended Euclidean algorithm. The second approach uses Fermat's theorem and a fast algorithm for computing modular powers (see MDEXP for the fast powering algorithm).

### Maple Worksheet

• giavg.mws(Solution to assignment 3 - Gaussian integer relative primality probability calculation and calculation of the average number of divisions in the Euclidean algorithm)
• tiprod.mws(Analysis of the computing time of the SACLIB algorithm IPROD for computing arbitrary precision integer products).

### Assignment

Created: Jan. 27, 2000 by jjohnson@mcs.drexel.edu