Posts Tagged ‘Geometry’

IMO 2018 Problems – Day 2

July 10, 2018 Leave a comment

Problem 4. A site is any point {(x, y)} in the plane such that {x} and {y} are both positive integers less than or equal to 20.

Initially, each of the 400 sites is unoccupied. Amy and Ben take turns placing stones with Amy going first. On her turn, Amy places a new red stone on an unoccupied site such that the distance between any two sites occupied by red stones is not equal to {\sqrt{5}}. On his turn, Ben places a new blue stone on any unoccupied site. (A site occupied by a blue stone is allowed to be at any distance from any other occupied site.) They stop as soon as a player cannot place a stone.

Find the greatest {K} such that Amy can ensure that she places at least {K} red stones, no matter how Ben places his blue stones.

Problem 5. Let {a_1,a_2,\ldots} be an infinite sequence of positive integers. Suppose that there is an integer {N > 1} such that, for each {n \geq N}, the number

\displaystyle \frac{a_1}{a_2} + \frac{a_2}{a_3} + \ldots + \frac{a_{n-1}}{a_n} + \frac{a_n}{a_1}

is an integer. Prove that there is a positive integer {M} such that {a_m = a_{m+1}} for all {m \geq M}.

Problem 6. A convex quadrilateral {ABCD} satisfies {AB\cdot CD = BC\cdot DA}. Point {X} lies inside {ABCD} so that {\angle{XAB} = \angle{XCD}} and {\angle{XBC} = \angle{XDA}}. Prove that {\angle{BXA} + \angle{DXC} = 180}.

Source: AoPS


IMO 2018 Problems – Day 1

July 9, 2018 Leave a comment

Problem 1. Let {\Gamma} be the circumcircle of acute triangle {ABC}. Points {D} and {E} are on segments {AB} and {AC} respectively such that {AD = AE}. The perpendicular bisectors of {BD} and {CE} intersect minor arcs {AB} and {AC} of {\Gamma} at points {F} and {G} respectively. Prove that lines {DE} and {FG} are either parallel or they are the same line.

Problem 2. Find all integers {n \geq 3} for which there exist real numbers {a_1, a_2, \dots a_{n + 2}} satisfying {a_{n + 1} = a_1}, {a_{n + 2} = a_2} and

\displaystyle a_ia_{i + 1} + 1 = a_{i + 2}

For {i = 1, 2, \dots, n}.

Problem 3. An anti-Pascal triangle is an equilateral triangular array of numbers such that, except for the numbers in the bottom row, each number is the absolute value of the difference of the two numbers immediately below it. For example, the following is an anti-Pascal triangle with four rows which contains every integer from {1} to {10}

\displaystyle 4

\displaystyle 2\quad 6

\displaystyle 5\quad 7 \quad 1

\displaystyle 8\quad 3 \quad 10 \quad 9

Does there exist an anti-Pascal triangle with {2018} rows which contains every integer from {1} to {1 + 2 + 3 + \dots + 2018}?

Source: AoPS.

Balkan Mathematical Olympiad 2018

June 23, 2018 Leave a comment

Problem 1. A quadrilateral {ABCD} is inscribed in a circle {k}, where {AB>CD} and {AB} is not parallel to {CD}. Point {M} is the intersection of the diagonals {AC} and {BD} and the perpendicular from {M} to {AB} intersects the segment {AB} at the point {E}. If {EM} bisects the angle {CED}, prove that {AB} is a diameter of the circle {k}.

Problem 2. Let {q} be a positive rational number. Two ants are initially at the same point {X} in the plane. In the {n}-th minute {(n=1,2,...)} each of them chooses whether to walk due north, east, south or west and then walks the distance of {q^n} meters. After a whole number of minutes, they are at the same point in the plane (non necessarily {X}), but have not taken exactly the same route within that time. Determine all the possible values of {q}.

Problem 3. Alice and Bob play the following game: They start with two non-empty piles of coins. Taking turns, with Alice playing first, each player chooses a pile with an even number of coins and moves half of the coins of this pile to the other pile. The came ends if a player cannot move, in which case the other player wins.

Determine all pairs {(a,b)} of positive integers such that if initially the two piles have {a} and {b} coins, respectively, then Bob has a winning strategy.

Problem 4. Find all primes {p} and {q} such that {3p^{q-1}+1} divides {11^q+17^p}.


FreeFem++ Tutorial – Part 2

Click here for the first part. Some other posts related to FreeFem: link 1, link 2.

Here are a few tricks, once you know the basics of FreeFem. If your plan is straightforward: define the domain, build the mesh, define the problem, solve the problem, plot the result… then things are rather easy. If you want to do stuff in a loop, like an optimization problem, things may get more complicated, but FreeFem still has lots of tricks up its sleeves. I’ll go through some of them.

  1. Defining the geometry of the domain using border might be tricky at the beginning. Keep in mind that the domain should be on the left side of the curves definining the boundaries. This could be acheived in the parametrization chosen or you could reverse the parametrization of a particular part of the domain in the following way. Suppose you have the pieces of boundary C1,C2,C3,C4. You wish to build a mesh with the command mesh Th = buildmesh(C1(100)+C2(100)+C3(100)+C4(100));but you get an error concerning a bad sens on one of the boundaries. If you identify, for example, that you need to change the orientation of C3, you can acheive this by changing the sign of the integer defining the number of points on that part of the boundary: mesh Th = buildmesh(C1(100)+C2(100)+C3(-100)+C4(100));You could make sure that you have the right orientations and good connectivities for all the boundaries by running a plot command before trying mesh: something like


    should produce a graph of all your boundaries with arrows showing the orientations. This is good as a debug tool when you don’t know where the error comes from when you define the domain.

  2. Keep in mind that there are also other ways to build a mesh, like square, which meshes a rectangular domain with quite a few options and trunc which truncates or modifies a mesh following some criteria. Take a look in the documentation to see all the options.
  3. Let’s say that you need to build a complex boundary, but with many components with similar properties. Two examples come to mind: polygons and domains with many circular holes. In order to do this keep in mind that it is possible to define a some kind of “vectorial boundary”. Let’s say that you want to mesh a polygon and you have the coordinates stored in the arrays xs,ys. Furthermore, you have another array of integers ind which point to the index of the next vertex. Then the boundary of the polygon could be defined with the following syntax:
    border poly(t=0,1; i){
    Now the mesh could be constructed using a vector of integers NC containing the number of desired points on each of the sides of the polygon:

    mesh Th = buildmesh (poly(NC));
  4. You can change a 2D mesh using the command adaptmesh. There are various options and you’ll need to search in the documentation for a complete list. I use it in order to improve a mesh build with buildmesh. An example of command which gives good results in some of my codes is:

    Th = adaptmesh(Th,0.02,IsMetric=1,nbvx=30000);

    The parameters are related to the size of the triangles, the geometric properties of the griangles and the maximal number of vertices you want in your mesh. Experimenting a bit might give you a better idea of how this command works in practice.
  5. There are two ways of defining the problems in FreeFem. One is with solve and the other one is with problem. If you use solve then FreeFem solves the problem where it is defined. If you use problem then FreeFem remembers the problem as a variable and will solve it whenever you call this variable. This is useful when solving the same problem multiple times. Note that you can modify the coefficients of the PDE and FreeFem will build the new problem with the updated coefficients.
  6. In a following post I’ll talk about simplifying your code using macros and functions. What is good to keep in mind is that macros are verbatim code replacements, which are quite useful when dealing with complex formulas in your problem definition or elsewhere. Functions allow you to run a part of the code with various parameters (just like functions in other languages like Matlab).

I’ll finish with a code which computes the eigenvalue of the Laplace operator on a square domain with multiple holes. Try and figure out what the commands and parameters do.

int N=5; //number of holes
int k=1; //number of eigenvalue

int nb = 100;  // parameter for mesh size
verbosity = 10; // parameter for the infos FreeFem gives back

real delta = 0.1;
int nbd = floor(1.0*nb/N*delta*2*pi);

int bsquare = 0;
int bdisk   = 1;

// vertices of the squares
real[int] xs(N^2),ys(N^2);

real[int] initx = 0:(N^2-1);
for(int i=0;i<N^2;i++){
  xs[i] = floor(i/N)+0.5;
  ys[i] = (i%N)+0.5;

cout << xs << endl;
cout << ys << endl;

int[int] Nd(N^2);

Nd = 1;
Nd = -nbd*Nd;

cout << Nd << endl;

// sides of the square
border Cd(t=0,N){x = t;y=0;label=bsquare;}
border Cr(t=0,N){x = N;y=t;label=bsquare;}
border Cu(t=0,N){x = N-t;y=N;label=bsquare;}
border Cl(t=0,N){x = 0;y=N-t;label=bsquare;}

border disks(t=0,2*pi; i){


mesh Th = buildmesh(Cd(nb)+Cr(nb)+Cu(nb)+Cl(nb)+disks(Nd));


int[int] bc = [0,1]; // Dirichlet boundary conditions

load "Element_P3";
fespace Vh(Th,P2);
// variables on the mesh
Vh u1,u2;

// Define the problem in weak form
varf a(u1,u2) = int2d(Th)
(dx(u1)*dx(u2) + dy(u1)*dy(u2))+on(1,u1=0)//on(C1,C2,C3,C4,u1=1)
varf b([u1],[u2]) = int2d(Th)(  u1*u2 ) ;
// define matrices for the eigenvalue problem
matrix A= a(Vh,Vh,solver=Crout,factorize=1);
matrix B= b(Vh,Vh,solver=CG,eps=1e-20); 

// we are interested only in the first eigenvalue
int eigCount = k;
real[int] ev(eigCount); // Holds eigenvalues
Vh[int] eV(eigCount);   // holds eigenfunctions
// Solve Ax=lBx
int numEigs = EigenValue(A,B,sym=true,sigma=0,value=ev,vector=eV);

cout &lt;&lt; ev[k-1] &lt;<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>&lt; endl;


Here is the mesh and the solution given by the above program:


Spherical triangles of area Pi

April 6, 2018 Leave a comment

Recently I stumbled upon this page and found out a very nice result:

If a spherical triangle has area \pi then four copies of it can tile the sphere.

Here we are talking about triangles on the unit sphere whose edges are geodesics. The above result is a simple consequence of the following facts:

  1. If a spherical triangle has angles \alpha,\beta,\gamma then its area is \alpha+\beta+\gamma-\pi. Therefore if a triangle has area \pi, then \alpha+\beta+\gamma = 2\pi.
  2. If ABC is a triangle of area \pi and D is obtained by symmetrizing A with respect to the midpoint of BC on the sphere, then DCB and ABC are congruent triangles.
  3. Using angles and the fact that on the sphere similar triangles are congruent, we obtain that the triangles ABC,BCD,CDA,DAC are all congruent.

Here are a few examples of such partitions:

Mesh a hollow sphere

April 5, 2018 Leave a comment

This is an interesting experiment I’ve done today and I’d like to share it. There are nice software out there which allow you to mesh regular surfaces, like the sphere, torus or other examples.

I needed something different: I wanted to mesh a sphere with a hole and an inner surface. This kind of surfaces may be useful for those who want to design objects for 3D printing. When using 3D printers, the cost is usually proportional to the volume of material used, since this also consumes impression time. If you manage to make a hollow object, the cost goes down immediately (as the resistance of the object…). However, to make a hole, you need to consider an inner parallel surface. I’ll not handle this here, since it’s more complicated. I’ll just mesh a hollow sphere.

I did this in Matlab using the nice library Distmesh, which is free and really easy to use. The whole difficulty was making a function whose zero level set is the hollow sphere. Recall that it is possible to find the union of two shapes using the minimum of two level set function and the intersection using the maximum. This is all that you need to understand what I did below. You can see the details in the Matlab code below.

function [p,t] = Hole_Spher_Mesh(mh)

  R = 0.5;
  r = 0.4;
  rh = 0.1;

  fh=@(p) sqrt(min(p(:,1).^2+p(:,2).^2,ones(size(p(:,1)))));
  fh=@(p) sqrt((p(:,1).^2+p(:,2).^2));
  points = p';
  npt = prod(size(points))/3


function res = fd(p,R,r,rh)

res1 = sqrt(sum(p.^2,2))-R;
res2 = (rh-sqrt(p(:,1).^2+p(:,2).^2));
res3 = p(:,3);
res2 = max(-res2,res3);
res4 = sqrt(sum(p.^2,2))-r;
res2 = min(res2,res4);
res = max(res1,-res2);

And here is the resulting surface for the parameter mh = 0.01 (if you put a higher precision computations will take longer).


Romanian Masters in Mathematics contest – 2018

March 9, 2018 Leave a comment

Problem 1. Let {ABCD} be a cyclic quadrilateral an let {P} be a point on the side {AB.} The diagonals {AC} meets the segments {DP} at {Q.} The line through {P} parallel to {CD} mmets the extension of the side {CB} beyond {B} at {K.} The line through {Q} parallel to {BD} meets the extension of the side {CB} beyond {B} at {L.} Prove that the circumcircles of the triangles {BKP} and {CLQ} are tangent .

Problem 2. Determine whether there exist non-constant polynomials {P(x)} and {Q(x)} with real coefficients satisfying

\displaystyle P(x)^{10}+P(x)^9 = Q(x)^{21}+Q(x)^{20}.

Problem 3. Ann and Bob play a game on the edges of an infinite square grid, playing in turns. Ann plays the first move. A move consists of orienting any edge that has not yet been given an orientation. Bob wins if at any point a cycle has been created. Does Bob have a winning strategy?

Problem 4. Let {a,b,c,d} be positive integers such that {ad \neq bc} and {gcd(a,b,c,d)=1}. Let {S} be the set of values attained by {\gcd(an+b,cn+d)} as {n} runs through the positive integers. Show that {S} is the set of all positive divisors of some positive integer.

Problem 5. Let {n} be positive integer and fix {2n} distinct points on a circle. Determine the number of ways to connect the points with {n} arrows (oriented line segments) such that all of the following conditions hold:

  • each of the {2n} points is a startpoint or endpoint of an arrow;
  • no two arrows intersect;
  • there are no two arrows {\overrightarrow{AB}} and {\overrightarrow{CD}} such that {A}, {B}, {C} and {D} appear in clockwise order around the circle (not necessarily consecutively).

Problem 6. Fix a circle {\Gamma}, a line {\ell} to tangent {\Gamma}, and another circle {\Omega} disjoint from {\ell} such that {\Gamma} and {\Omega} lie on opposite sides of {\ell}. The tangents to {\Gamma} from a variable point {X} on {\Omega} meet {\ell} at {Y} and {Z}. Prove that, as {X} varies over {\Omega}, the circumcircle of {XYZ} is tangent to two fixed circles.

Source: Art of Problem Solving forums

Some quick ideas: For Problem 1 just consider the intersection of the circle {(BKP)} with the circle {(ABCD)}. You’ll notice immediately that this point belongs to the circle {(CLQ)}. Furthermore, there is a common tangent to the two circles at this point.

For Problem 2 we have {10\deg P = 21 \deg Q}. Eliminate the highest order term from both sides and look at the next one to get a contradiction.

Problem 4 becomes easy after noticing that if {q} divides {an+b} and {cn+d} then {q} divides {ad-bc}.

In Problem 5 try to prove that the choice of start points determines that of the endpoints. Then you have a simple combinatorial proof.

Problem 6 is interesting and official solutions use inversions. Those are quite nice, but it may be worthwhile to understand what happens in the non-inverted configuration.

I will come back to some of these problems in some future posts.

%d bloggers like this: