# Welcome to Introduction to Programming and Numerical Analysis

*"This course has been amazing. It feels like i'm weaponizing the text-book theory from other courses."* (student evaluation)

**Course responsible:**

Jeppe Druedahl, Assistant Professor, University of Copenhagen, Center for Economic Behavior and Inequality.

Christian Langholz Carstensen, Postdoc, University of Copenhagen, Center for Computational Economics.

This course introduces you to programming and enables you to numerically solve simple economic models and perform basic data analysis. This will e.g. allow you to both visualize solutions, easily test assumptions with respect to functional forms and parameters, and consider more realistic models, which are solvable numerically but not algebraically.

We will mostly use the **Python** programming language, and focus on well-known microeconomic and macroeconomic models from the core bachelor courses (Edgeworth, Koopman, Solow, AS-AD etc.). The course requires you to get your hands dirty - programming is not a spectator sport!

Once you are done with the course, you will have learned all of the tools necessary for programming a numerical solution algorithm for any economic model you face in your undergraduate and graduate courses.

The course is divided into four parts:

**Fundamentals:**Print, plot, optimize, simulate, document, work-flow.**Working with data:**Fetch, combine, split-apply-combine, visualize.**Algorithms:**Pseudo code, algorithms, complexity, solve, symbolic.**Further perspectives:**Comprehensions, generators, vectorization, parallization, timing, Numba.

**Details:** See the **course plan**, the lectures **lectures**, and the **exercises**.

**Datacamp:** All students attending the course will receive 6 months of free access to **DataCamp** (you will receive an e-mail regarding this). In the first classes you will follow online courses at DataCamp to learn the basics of Python.

**Github:** The course is centered arround two GitHub repositories in **NumEconCopenhagen**:

**lectures-2022**: Slides and code for the lectures**exercises-2022**: Problem sets with solutions

**Self-study:** You can also go through this course as self-study. Details are provided **here**.

### Guides

To follow this course you need:

In the **first set** of guides you learn how install and run Python:

Running Python in JupyterLab (see also: Writing markdown)

In the **second set** of guides you learn how to search for answers, ask questions and use git:

### Course Description

This course introduces you to programming and enables you to numerically solve simple economic models and perform basic data analysis. This will e.g. allow you to both visualize solutions, easily test assumptions with respect to functional forms and parameters, and consider more realistic models, which are solvable numerically but not algebraically.

The course requires no prior experience with programming.

The first part of the course introduces you to programming using the general-purpose Python language. You will learn to write conditional statements, loops, functions, and classes, and to print results and produce static and interactive plots. You will learn to solve simple numerical optimization problems, and draw random number and run simulations. You will learn to test, debug and document your code, and use online communities proactively when writing code.

The second part of the course give you a brief introduction on how to import data from offline and online sources, structure it, and produce central descriptive statistics. You will learn to estimate simple statistical models on your data.

The third part of the course introduce you to the concept of a numerical algorithm. You will learn how to write simple searching, sorting and optimization algorithms. You will learn to solve linear algebra problems, solve non-linear equations numerically and symbolically, find fixed points, and solve complicated numerical optimization problems relying on function approximation.

You will get hands-on experience with applying the above techniques to solve well-known microeconomic and macroeconomic problems from the core bachelor courses. Specifically, you will work with both a small data analysis project, and a larger model analysis project based on a well-known economic model.

While the course only focus on programming in Python, you will also be equipped to start learning other programming languages (such as MATLAB, R, Julia or even C/C++) on your own.

*For exam information and further details see kurser.ku.dk.*

### Learning Outcomes

**Knowledge:**

Describe the differences between data types (e.g. strings, booleans, integers and floats)

Describe the differences between data containers (e.g. lists, dicts and arrays)

Explain the use of conditionals (if-elseif-else)

Explain the use of loops (for, while, continue, break)

Explain the use of functions, methods and classes

Describe the difference between views and copies of objects

Explain how to use (pseudo) random numbers

Explain the notation of numerical algorithms

**Skills:**

Setup a Python enviroment

Write Python scripts, functions and notebooks

Apply error handling and debugging techniques

Use and write code documentation

Print results and make static and interactive plots

Import and export of data from and to csv, excel and online databases

Perform simple descriptive analysis of numerical data

Use numerical equation solvers

Use symbolic equation solvers

Use numerical optimizers

Formulate numerical algorithms from mathematical problems

**Competencies:**

Work collaboratively on code projects

Use online communities to find existing code and get help

Solve mathematical problems numerically

Solve well-known economic problems numerically

Perform numerical simulation of stochastic models

Present and discuss results of a numerical analysis

Learn new programming tools and languages

### Other ressources

**More:** Some recommended online ressources for learning programming relevant to economics are: