MAT 331: Computer-Assisted Mathematical Problem Solving

Fall 2018

Christopher Bishop

Professor, Mathematics
SUNY Stony Brook

Office: 4-112 Mathematics Building
Phone: (516)-632-8274
Dept. Phone: (516)-632-8290
FAX: (516)-632-7631

TuTh 11:30-12:50 Math Tower S-235S (computer lab in basement)

Office hours 10-11:20, Tuesday and Thursday, and by appointment.

No Final Exam
If you are doing a third project, it is due (at my office, 4-112 Math Tower) at the beginning of the scheduled final exam time 11:15-1:45 Wednesday, December 19

The webpage for Fall 2017 is for the same class, but a slightly different choice of topics.

This is a course in problem solving using MATLAB. This is commercial software produced by the company Mathworks, and is commonly used throughout academia and industry. We may do a proof here and there, but the main focus is on computing and experimenting. You will graded on three basic skills: the ability to use MATLAB commands we have discussed in class to perform a specific calculaion and get the right answer; the ability to take a written decription of a formula or algorithm and turn it into code; and the ability to clearly describe what your code does using written English, embelished with tables, charts and figures. The first catefory will be evaluated by in class quizes and the latter two by homework assignments and written projects (the projects are very similar to homework assignments, except that they are a little longer and you get to choose the topics from a list I prepare).

Among the mathematical topic we may explore are (this list is subject to deletions and substitutions):
        Prime numbers
        Graph theory, random graphs
        Expander graphs
        Random walks, harmonic measure
        DLA (Diffusion Limited Aggregation)
        Root finding, Newton's method
        The Mandelbrot set
        Polynomial interpolation, Chebyshev nodes, Chebfun
        Shift codes, Substitution codes
        Letter frequency, digrams
        One time pads, Venona

We will start by going through most of Tobin Driscoll's short book "Learning MATLAB" for the first few weeks to learn the basic commands. We will then do various topics in cryptography, probability, graph theory, approximation theory (and whatwever we can fit into the course) using materials I put on the website. There is a lot of interesting material in Cleve Moler's books "Numerical Computing in MATLAB: revised reprint" and "experiments in MATLAB", as well a few articles and blog entries by Moler from the Mathworks site. Moler is the original creator of MATLAB. Moler's books can be purchased as hard-copies, but there are also a free online versions provided by MathWorks (the company the produces MATLAB); you will need to create a MathWorks Account.

Learning MATLAB by Toby Driscoll. Amazon site for a very good, very short and inexpensive introduction to MATLAB, by a real expert.

SIAM site for buying of "Learning MATLAB" by Tobin Driscoll.

Numerical Computing in MATLAB: revised reprint by Cleve Moler. Chapters can be downloaded individually. There is also a collection of MATLAB code to download and that is used in the text. There are lots of good examples here, and this is an excellent introdcution to MATLAB by its creator, but we will not follow it closely in class.

SIAM site for buying hardcopy of "Numerical Computing in MATLAB: revised reprint by Cleve Moler.

Numerical Computing in MATLAB: revised reprint by Cleve Moler. Chapters can be downloaded individually. There is also a collection of MATLAB code to download and that is used in the text. There are lots of good examples here, and this is an excellent introdcution to MATLAB by its creator, but we will not follow it closely in class.

SIAM site for buying hardcopy of "Numerical Computing in MATLAB: revised reprint by Cleve Moler.

The university has a WRTD writing requirement that can be fulfilled by submitting two of the projects from this class. If you intend to fulfill the requirement this way, you should register for the zero-credit course MAT 459, and let me know you want to use your MAT 331 projects for this requirement. I will post possible projects as the semester proceeds and we will discuss a few in class two.

MATLAB is installed on machines in the SINC sites and is available from any computer via the virtual SINC site Virtual SINC site. .

Scripts and functions should be saved in your MySBFiles directory; other dirctories on the SINC site machines are erased after 48 hours. These MySBFiles can be accessed directly from any machine with an internet connection at MySBFiles .

The university license also allows you to download a copy to your home computer (if you are currently a student or faculty member): Information on downloading a copy of MATLAB This page also has instructions on how to create a MATHWORKS account,which you will need to access MATLAB programs and textbooks, even if you don't download a personal copy of MATLAB.

Grades will be based on (each counts equally):
(1) In-class quizzes. I provide practice quizzes to do at home.
(2) Homework. These will usually involving writing a short report stating the problem, describing how to solve it, giving the MATLAB code you used, and table or pictures that illustrate your results.
(3) Projects: just like homework, but a little longer and often involving some outside reading. I will make up several of these and you will choose two to do. If you want to improve your grade, you may choose to do a third project to replace one of the first two.

Send the lecturer (C. Bishop) email at: bishop - at -

Link to history of mathematics There are a lot of iteresting articles here. If you know of other math related sites I should link to, let me know.

A link to MathSciNet (Online Mathematical Reviews). These gives access to reviews of about 3 million mathematical papers and links to some of the actual articles. You will need a NETID and password to access this.

A link to the Stony Brook virtual SINC site . You will need a NETID and password to access this.

The not too short introduction to LaTex

A link to the installer for TexMaker. on the SINC site machines. You can also download for use on the virtual SINC site. This is special editor for TeX files that incorporates several steps into one. You will need a NETID and password to access this.

Markup in MATLAB publish This gives some tips on how to write a MATLAB script to be pushished (how to create titles, insert bold or italics charactgers, how to insert LaTeX formulas,....

Class Projects

Projects are longer versions of the homework assigments, but I will give several and you need to choose any three to hand in. If you are enrolled in MAT 459, then two of these can be used to satisfy the university WRDT requirement, as described above.

The first project is due November 8, and the second November 29. If you want to do a third one, it will be due December 19 (at my office). You may submit either a hardcopy or electronic version (but I would prefer a hardcopy to make sure it is printed just as you intend).

If you scored less than 80/100 on the first project, you may hand in a revised version for a possibly higher grade (at most 80) on or before November 29. The second project is still due on November 29.

Each listed project has two components for you to look at. The first is a one page description of what I want you to do. This will often include an itemized list of computations I want you to make, based on the reading the second part. The second will usually be a some notes written by myself, or a short recent paper by some mathematician describing a calculation or algorithm. Usually there will be more material here than you need to do the project; I generally only want you to do and describe experiments that test the claims of the paper, and you generally don't have to understand the proofs in the paper to do this.

Projects for Thursday, November 8 (you may hand this one in on Tuesday, Nov 13):

        Project - The giant component ,
                Bollabas paper on random graphs
                Wikipedia page on Giant Component

        Project - perfect matchings ,
                Notes on Tutte's perfect matching criteria.
                different notes on Tutte's perfect matching criteria

        Project - Points of increase ,
                Points of increase for random walks , by Yuval Peres, Microsoft Research

        Project - fractal dimension ,
                YouTube video explaining idea of fractals and dimension

Projects for Thursday, November 29. You may also do one of the projects listed above (a different one that you did for the first project). I will also consider alternative topics for projects, but you should first discuss the idea with me and get my approval before handing it in.
        Project - random permuations of the alphabet , ----- Solving a random permutation substitution

        Project - solving a random shift code , -----

        Project - distinguishing authors , -----

        Project - one time pads , ----- Breaking a re-used one time pad

        Project - Mandelbrot set , ----- Estimate the area of the Mandelbrot set using random sampling

How to write up the projects

The write-up is supposed to be a short report that explains what the problem is and how you solved it, including any samples of code or output (such as tables or plots). Think of it like an essay for an English or History class except that it is written about a math problem, instead of about Jane Austin or the French revolution. There should be an introduction that describes the problem, a main body that gives the details of your solution and a conclusion the briefly summarizes your results.

Some good things to do include:
        Put titles on your plots
        Insert comments into code saying what role named arrays play and what loops are doing
        supress intermediate calculations and display a single table of results at end
        when comparing two or more arrays, present them as columns of a single table/array
        when plotting an approximation to a function, also plot the function so we can see how close they are. Also consider plotting (separately) the difference of the two.

Tentative Lecture Schedule

Tuesday, August 28 Introduction
        Cleve's Corner - The origin of MATLAB ,
        Topics covered:
        course administration, the class webpage,
        how to access the virtual SINC site,
        how to open MATLAB, open documentation,
        format long, pi
        basic arithmetic, digits, vpa
        sqrt, sin, ex, char, strfind
        vectors and matrices, zeros, ones, colon operator, sum

Thursday, August 30 More basic MATLAB
        Scripts for Aug 30
        On Tuesday, plotting did not work correctly. This is supposed to be fixed now on the SINC site computers, but if not, then after starting MATLAB, type the command opengl('save','software') . It might be necessary to restart MATLAB.
        Topics covered:
        MySBSFiles, creating a directory, subdirectories
        save, load
        plot, scatter, scatter3, figure, hist, hold on, grid on, title, legend
        Practice Quiz 1 and Solutions for practice Quiz 1

Tuesday, September 4 Quiz 1 during last 30 minutes of class
        Solutions for Practice Quiz 1
        Scripts for Sept 4
        Topics covered:
        find, logical indexing

Thursday, September 6
        Scripts for Sept 6
        Homework 0 (PDF) -- sample homework
        Homework 0 solution using MATLAB script -- sample solution in recommended format
        Homework 0 (TEX) -- LaTex file used to create hw0.pdf

Tuesday, September 11
        Scripts for Sept 11
        Topics covered:
        tic, toc, profiling, pre-allocation of memory
        random n-vectors, normal distribution, rand, randn, randi
        polynomials in MATLAB, polyval, polyder, roots
        Newton's method
        anonymous functions, ezplot, fzero

Thursday, September 13 Homework 1 due
        Scripts for Sept 13
        Homework 1 - volumes of n-balls
        Wikipedia - volumes of n-balls
        Practice Quiz 2
        Solutions for Practice Quiz 2
        Topics covered:
        arrays: size,length
        matrix multiplication, solving, det, eigs
        basic linear algebra

Tuesday, September 18 Quiz 2, last 30 minutes of class
        Solutions for Quiz 2
        No new material today.

Thursday, September 20
        Scripts for Sept 20

        Topics covered: images, imread, imshow, uint8, rgb2gray

Tuesday, September 25
        Scripts for Sept 25
        Homework 2 due date moved to Oct 2.
        Johnson-Lindenstrauss lemma, Wikipedia
        An Elementary proof of the Johnson-Lindenstrauss lemma , by Sanjoy Dasgupta, and Anupam Gupta.
        Dimension reduction , by Nick Harvey.

Thursday, September 27
        Gauss Prize Citation for David Donoho ,
        Compressive Sensing: from blackboard to beside , Donoho's Gauss prize lecture at the International Congress of Mathematicians. His lecture is recap (with additional comments) of presentation he made to members of Congress and staffers about how mathematical research effects peoples lives.
        From Blackboard toBedside: how high dimensional geometry is transforming the MRI industry , Written summary of Donoho's presentation.
        Mathematicians helping art historians and art conservators , Public lecture by Ingrid Debauchies on applications of math to art history. Introduction is in Portuguese; lecture is in English, starting at time 2:25. Prof Debauchies is one of world's leading experts on wavelets and image processing.

Tuesday, October 2
        Homework 2 due date moved to from Sept 25. Homework 2 - Image compression
        Scripts for Oct 2
        Topics covered: basic graph theory, vertex, edge, degree, adjacency matrix, connected graphs, connected components, shortest paths, spanning trees, bi-partite graphs, four-color theorem

Thursday, October 4
        practice quiz 3, solutions. For the practice quiz use the graphs found in graphs.mat which is save in the list of Scripts for Oct 4. The actual quiz will use a different collection of graphs; a link will be given below under October 11.
        Scripts for Oct 4
        Topics covered: degree, matrix, connected graphs, connected components, shortest paths, spanning trees

Tuesday, October 9 Fall Break, No class

Thursday, October 11 Quiz 3 (last 30 minutes of class)
        graphs_quiz3.mat 20 adjacency matrices for use in Quiz 3.
        Scripts for Oct 11

Tuesday, October 16
        Topics covered: random graphs, giant component
        Bollabas paper on random graphs
        photo of Bollabas and myself at 2018 ICM.
        Wikipedia page on Giant Component
        Tutte's perfect matching criteria
        Tutte's perfect matching criteria, 2nd version

Thursday, October 18
        Practice Quiz 4, Solutions. Real Quiz, Thursday Oct 25
        Scripts for Oct 18, Cryptology
        ASCII code
        Project Gutenberg
        National Cryptologic Museum
        Wikipedia - Ultra (World war II)
        Wikipedia - VENONA (Soviet spying in US)

Tuesday, October 23 More on cryptology, go over practice quiz 4
        Topics covered:
        simplify_text.m = drop non-letters, convert letter to uppercase
        caesar0.m = apply caesar code to typed input
        caesar2.m = apply caesar code to named input file
        count_common_words.m = count number of words in file from short list of common words
        pair_freq.m = count 2-grams in a given text
        count_pairs.m = score text for English using 2-gram counts created by pair-freq
        Google n-gram viewer, counts how often a word or phrase has occured in published work since 1800.
        The scripts prob4, prob5, prob6 written in class have been saved in Crypt folder.

Thursday, October 25 Quiz today, last 30 minutes of class, quiz solutions.

Tuesday, October 30
        Identifying English with digrams, break_caesar2.m, count_pairs.m
        Solving random substitution codes with letter counts

Thursday, November 1
        Letter frequencies to breaks random permutation substitutions.
Tuesday, November 6
        Questions about projects.

Thursday, November 8
        RSA (Rivest, Shamir, Adleman)
                RSA cryptosystem - Wikipedia
        RSA factoring challenge - Wikipedia
        One-time pad - Wikipedia
        VENONA project - Wikipedia
        Enigma machine - Wikipedia
        Ultra - Wikipedia

Tuesday, November 13 Project I due
        Iteration scripts
        Topics covered:
        Newton's method, rational iterations, Mandelbrot set, Julia set
        Benoit Mandelbrot
        Gaston Julia
        Pierre Fatou
        Dennis Sullivan
        John Milnor

Thursday, November 15
        Histogram for Project 1
        Histogram for approximate course totals (average of hohomework percent, quiz percent and project percent)
        the Julia set
        the Mandelbrot set

Tuesday, November 20 no class

Thursday, November 22 Thanksgiving, no class

Tuesday, November 27 Finish Mandelbrot, start random walks
        scripts related to random walks
        Wikipedia - Random walks
        Wikipedia - the central limit theorem
        Wikipedia - the error function
        Wikipedia - physical Brownian motion
        Wikipedia - Albert Einstein
        Wikipedia - Norbert Weiner
        Fractals in Probability and Analysis
by Bishop and Peres.
Thursday, November 29

Tuesday, December 4

Thursday, December 6 Last class

Wednesday, December 19 Optional thrird project due, 11:15am, at my office. 4-112 Math Tower.

Some random math links:

Stephen Wolfram blog on Ramanujan

Technology Support: Student Technology Services. TLT provides academic technology support to all students. If you require assistance with Blackboard or other academic technologies, please contact TLT at:; Phone: 631.632.9602; Chat; or visit a SINC Site.
Students who need assistance with their personal devices can contact DoIT's service desk at: 631.632.9800, submit an online request, or visit the Walk In Center on the 5th floor of the Melville Library (West Campus), Room S-5410. For more information, visit:

The University Senate Undergraduate and Graduate Councils have authorized that the following required statements appear in all teaching syllabi (graduate and undergraduate courses) on the Stony Brook Campus.

DISABILITY SUPPORT SERVICES (DSS) STATEMENT: If you have a physical, psychological, medical, or learning disability that may impact your course work, please contact Disability Support Services at (631) 632-6748 or They will determine with you what accommodations are necessary and appropriate. All information and documentation is confidential.

ACADEMIC INTEGRITY STATEMENT: Each student must pursue his or her academic goals honestly and be personally accountable for all submitted work. Representing another person's work as your own is always wrong. Facultyare required to report any suspected instances of academic dishonesty to the Academic Judiciary. Faculty in the Health Sciences Center (School of Health Technology and Management, Nursing, Social Welfare, Dental Medicine) and School of Medicine are required to follow their school-specific procedures. For more comprehensive information on academic integrity, including categories of academic dishonesty, please refer to the academic judiciary website at

CRITICAL INCIDENT MANAGEMENT: Stony Brook University expects students to respect the rights, privileges, and property of other people. Faculty are required to report to the Office of Judicial Affairs any disruptive behavior that interrupts their ability to teach, compromises the safety of the learning environment, or inhibits students' ability to learn. Faculty in the HSC Schools and the School of Medicine are required to follow their school-specific procedures.