Preface

These are the R programming notes for MATH245 Computational Mathematics. They were written by Gaetano Romano (Chapter 1-5) and Eduard Campillo-Funollet (Chapters 6-10).

The module will introduce you to scientific computing (with a bit of functional programming), and algorithms.

The first 5 Chapters will be focusing on scientific computing. Specifically, we’ll cover:

  1. Intro to computing, variables and saving to file

  2. Logic and Vectors

  3. Functions and Loops

  4. Functional Programming and Linear Algebra

  5. Data Frames and Plotting

Chapters 6 to 10 will be focusing on algorithms. We’ll cover:

  1. Fixed Points

  2. Root finding

  3. Gradient Descent

  4. Monte Carlo and Integration

  5. ODEs solvers

All contents are still subject to change. The notes are both in Python and R. You are expected to only learn one programming language. However, these notes could be used also as a reference to go from one language to the other! Please access them from a wide screen machine, as they were not optimized for mobile.

Every week, you are expected to follow one lecture and one lab. Over the lecture, an overview of the contents of the week will be given. But during the lab, you should give it a go at the notes at your own pace, and follow the contents by copy and pasting commands from the notes onto your pc, and completing the exercises. Solutions to the exercises will be uploaded on Moodle after all labs of the week end.

Sources

This notes are heavily inspired from the materials of including:

Some of the structure of the notes, some example and exercises are from:

  • Hadley Wickham: “Advanced R.” 2nd Edition. https://adv-r.hadley.nz/index.html.

  • Azalee Bostroem, Trevor Bekolay, and Valentina Staneva (eds): “Software Carpentry: Programming with Python.” Version 2016.06, June 2016, https://github.com/swcarpentry/python-novice-inflammation, 10.5281/zenodo.57492.

  • Gabriel A. Devenyi (Ed.), Gerard Capes (Ed.), Colin Morris (Ed.), Will Pitchers (Ed.), Greg Wilson, Gerard Capes, Gabriel A. Devenyi, Christina Koch, Raniere Silva, Ashwin Srinath, … Vikram Chhatre. (2019, July). swcarpentry/shell-novice: Software Carpentry: the UNIX shell, June 2019 (Version v2019.06.1). Zenodo. http://doi.org/10.5281/zenodo.3266823

Acknowledgments

The authors would like to thank Estevão Batista do Prado, Giovanna de Lauri, Katie Howgate, Lydia Kakampakou, Rebecca Killick, David Leslie, Florian Pein, Ophélie Schaller, and Chris Sherlock. Their invaluable contributions, encompassing insightful suggestions, diligent error-checking, and thoughtful exercise design, have significantly enriched this module.