## Identifying edges and boundary points – 2D Mesh – Matlab

A triangulation algorithm often gives as output a list of points, and a list of triangle. Each triangle is represented by the indexes of the points which form it. Sometimes we need extra information on the structure of the triangulation, like the list of edges, or the list of boundary points. I will present below two fast algorithms for doing this.

Finding the list of edges is not hard. The idea is to go through each triangle, and extract all edges. The algorithm proposed below creates the adjacency matrix in the following way: for each triangle we set the elements (and their symmetric correspondents) to be equal to .

In order to find the points on the boundary (in two dimensions), it is enough to look for the edges which are sides to only one triangle. We can do this using the adjacency matrix. Note that if is the adjacency matrix, then stores the number of paths of length (two sides) between two points of the triangulation. Note that any edge which is not on the boundary will contain the starting and ending point of two paths of length . If is a triangle such that points are on the boundary, then (there is one path of length going through . We also have . Conversely, if and then are connected, and there is a unique path of length going from to . Thus, is an edge on the boundary. Therefore, we just need to identify the indexes such that there exists with .

Below are two short Matlab codes doing these two algorithms. I guess they are close to being optimal, since only sparse and vectorized operations are used.

%p is the list of points %T is the list of triangles, ap is the number of points %this computes the adjacency matrix A = min(sparse(T(:,1),T(:,2),1,ap,ap)+sparse(T(:,2),T(:,3),1,ap,ap)+sparse(T(:,3),T(:,1),1,ap,ap),1); A = min(A+A',1); % this finds the boundary points, whose indexes are stored in Ibord B = A^2.*A==1; Ibord = find(sum(B,2)>0);

## Simple triangle mesh – Matlab code

There are cases when you need to define a simple, regular mesh on a *nice* set, like a triangle, or a polygon. There are software which are capable of creating such meshes, but most of them will require some computation time (Delaunay triangulation, plus optimization, edge swapping, etc.). I propose to you a simple algorithm for defining a mesh on a triangle. Of course, this can be extended to polygons or other cases (I used a variant of it to create a mesh of a spherical surface).

The idea is very simple: start with three points , and define the (only) initial triangle as . Then, at each step, take a triangle from the list , add the midpoints of to the list of points and replace the triangle with the four smaller triangles determined by the vertices and midpoints of . This is a basic mesh refining strategy. Thus, in short, we start with a triangle and do a number of mesh refinements, until we reach the desired side-length. Of course, at each step we should be careful not to add the midpoint of an edge two times (once for every neighbouring triangle), but in what follows, I will always remove duplicates by bruteforce in the end (not the most economic solution).

## Vojtech Jarnik Competition 2015 – Problems Category 2

**Problem 1.** Let and be two matrices with real entries. Prove that

provided all the inverses appearing on the left-hand side of the equality exist.

**Problem 2.** Determine all pairs of positive integers satisfying the equation

**Problem 3.** Determine the set of real values for which the following series converges, and find its sum:

**Problem 4.** Find all continuously differentiable functions , such that for every the following relation holds:

where

## Vojtech Jarnik Competition 2015 – Category 1 Problems

**Problem 1.** Let be differentiable on . Prove that there exists such that

**Problem 2.** Consider the infinite chessboard whose rows and columns are indexed by positive integers. Is it possible to put a single positive rational number into each cell of the chessboard so that each positive rational number appears exactly once and the sum of every row and of every column is finite?

**Problem 3.** Let and . Determine for each of the polynomials and whether it is a divisor of some nonzero polynomial whose coefficients are all in the set .

**Problem 4.** Let be a positive integer and let be a prime divisor of . Suppose that the complex polynomial with and is divisible by the cyclotomic polynomial . Prove that there at least non-zero coefficients .

The cyclotomic polynomial is the monic polynomial whose roots are the -th primitive complex roots of unity. Euler’s totient function denotes the number of positive integers less than or eual to which are coprime to .

## Seemous 2015 Problem 1

**Problem 1.** Prove that for every the following inequality holds:

## Seemous 2015 Problems

**Problem 1.** Prove that for every the following inequality holds:

**Problem 2.** For any positive integer , let the functions be defined by , where . Solve the equation .

**Problem 3.** For an integer , let be matrices satisfying:

where is the identity matrix and is the zero matrix in .

Prove that:

- (a) and .
- (b) and .

**Problem 4.** Let be an open interval which contains and be a function of class such that .

- (i) Prove that there exists such that for .
- (ii) With determined at (i) define the sequence by
Study the convergence of the series for .

**Hints: **

## Putnam 2014 Problems

**A1.** Prove that every nonzero coefficient of the Taylor series of about is a rational number whose numerator (in lowest terms) is either or a prime number.

**A2.** Let be the matrix whose entry in the -th row and -th column is

for Compute

**A3.** Let and for Compute

in closed form.

**A4.** Suppose is a random variable that takes on only nonnegative integer values, with and (Here denotes the expectation of the random variable ) Determine the smallest possible value of the probability of the event

**A5.** Let Prove that the polynomials and are relatively prime for all positive integers and with

**A6.** Let be a positive integer. What is the largest for which there exist matrices and with real entries such that for all and the matrix product has a zero entry somewhere on its diagonal if and only if

**B1.** A *base over-expansion* of a positive integer is an expression of the form with and for all For instance, the integer has two base 10 over-expansions: and the usual base 10 expansion Which positive integers have a unique base 10 over-expansion?

**B2.** Suppose that is a function on the interval such that for all and How large can be?

**B3.** Let be an matrix with rational entries. Suppose that there are at least distinct prime numbers among the absolute values of the entries of Show that the rank of is at least

**B4.** Show that for each positive integer all the roots of the polynomial

are real numbers.

**B5.** In the 75th Annual Putnam Games, participants compete at mathematical games. Patniss and Keeta play a game in which they take turns choosing an element from the group of invertible matrices with entries in the field of integers modulo where is a fixed positive integer and is a fixed prime number. The rules of the game are:

(1) A player cannot choose an element that has been chosen by either player on any previous turn.

(2) A player can only choose an element that commutes with all previously chosen elements.

(3) A player who cannot choose an element on his/her turn loses the game.

Patniss takes the first turn. Which player has a winning strategy?

**B6.** Let be a function for which there exists a constant such that for all Suppose also that for each rational number there exist integers and such that Prove that there exist finitely many intervals such that is a linear function on each and