Archive for the ‘Teachings’ Category

Heidelberg Laurate Forum 2016

October 8, 2016 Leave a comment

I went to the 4th Heidelberg Laureate Forum and it was amazing. I encourage my students to apply and I am sure they will have a wow experience about how mathematics really is. Here is some of my thought about HLF 2016.

1. What an amazing tour, at a wonderful place.
I had an amazing experience, meeting with a lot of laureates, a lot of young and energetic researchers. We discuss a lot of things with one common thing which is mathematics. The meeting place could not have been better and Heidelberg is just perfect.

2. Mathematics meets his little own brother, computer science.
In this event, we did not only talk about math, we also talk about computer science which is so much younger than mathematics.

3.  Frontier between mathematics and computer science is not a fixed boundary, but it is actually an intersection.
Sir Michael Atiyah said this during the workshop. Read many Atiyah quotes here.

4.  Fermat last theorem
We saw the boy who is fascinated by Fermat’s last theorem. He solved it in 1994 and won the Abel’s prize.

5.  Euler proof of infinite prime
I like this proof of infinite prime and he solved it in the eighteenth century.

6. Deep learning perhaps should’t be named deep learning
Noel Sharkey mentioned that machine learning is nothing like learning, instead, it is a statistical parameter optimization.

7. Sometimes when you want to make things tidy, you find a new knowledge. This is what happens in tensor analysis. Vladimir Voevodsky had an idea to help verifying mathematical profs by computers and preserve intimate connection between maths and human intuition. He called this unimath.

8.  Something wrong in computer science education. Leslie Lamport cricitized computer science education as some of computer scientist did not understand the abstraction he made during the talk. He also said “Not every programming languages are as bad as C, but all prevent you from getting to a superior level of abstraction, he proposed Pluscal.”

9. I think Barbara Liskov is the only woman participating as the laureate in this forum. Wondering how many women have won Turing, Abel or Fields medal.

10. The last talk I remember was from Heisuke Hironaka, Fields Medalist in 1970. He gave many advises and one of those are  “Time is expensive, use it well”, ” You learn from your mates more than from your teacher” and” I want to write a book dedicated to my wife ” which was sweet.

I think that is all I can write. I really enjoy my experience in this forum. And now let’s end our journey at Heidelberg castle.



Taylor method with automatic differentiation – 2

July 20, 2016 Leave a comment

In the previous post, we have talked about Taylor method to solve ordinary differential equation (ODE) numerically. All the derivatives in the Taylor method are computed using automatic differentiation. However, the drawback of this method is when we change our ODE, we have to write another code. In this post, we are going to present a way such that when we want to compute another ODE, we don’t need to change the majority of our code.

Continuing our analysis in the last post, we are going to need operations on polynomials. We are going to define operations such as:

  1. Addition between a constant and a polynomial
  2. Multiplication between  a constant and a polynomial
  3. Addition between polynomials
  4. Multiplication between polynomials
  5. Dividing a constant by a polynomial
  6. Dividing a polynomial by a polynomial
  7. Logarithm of a polynomial
  8. Exponentiation of a polynomial
  9. Power of a polynomial

Operation 1 and 2 are trivial. Suppose x(h) is a polynomial, then x(h)=\sum x_i h^i for some real constant x_i. Suppose \alpha is a real constant, then the addition between \alpha and x(h) is a polynomial y(h) where y_0 = x_0 + \alpha and y_i = x_i for all i \geq 1. The multiplication between \alpha and x(h) is a polynomial z(h) where z_i = \alpha x_i for all i.

Operation 3 and 4 are not difficult. Suppose x(h), y(h) are polynomials. Then the addition between x(h) and y(h) is a polynomial z(h) where z_i = x_i + y_i for all i. The multiplication between x(h) and y(h) is a polynomial w(h) where w_i = \sum_{j=0}^{i} x_j y_{i-j}.

Operation 5 and 6 are a little bit tricky. Suppose x(h) is a polynomial and \alpha is a constant. We want to compute y(h) where y(h) = \alpha / x(h). Notice that x(h)y(h)=\alpha. Therefore, we are going to take advantage of this equality to find the coefficient of y(h). Thus we shall have y_0 = \alpha / x_0, and y_i = - (\sum_{j=1}^{i} x_j y_{i-j})/x_0. For operation 6, let’s suppose z(h) = y(h) / x(h). As before, notice that x(h)z(h) = y(h), thus we can compute the coefficient of z(h) using this equality. Thus, z_0 = y_0 / x_0 and z_i = (y_i - \sum_{j=1}^{i} x_j z_{i-j} )/x_0.

Now, let’s consider the next operation, which is a logarithm of a polynomial. Suppose x(h) is a polynomial and we are going to find y(h)=\log(x(h)). Let’s differentiate both side with respect to h, then we have y'(h) = x'(h) / x(h). Thus by exploiting a division operation above, we have y_0 = \log x_0 and y_i = (ix_i - (\sum_{j=1}^{i-1} x_j ((i-j)y_{i-j})))/(ix_0).

Now, let’s consider the exponential operator, which is an exponentiation of a polynomial. Suppose x(h) is a polynomial and we are going to find y(h)=\exp(x(h)). Let’s take logarithm on both side and then differentiate it, we then have y'(h)/y(h) = x'(h), or y'(h)=y(h)x'(h). Therefore, by exploiting a multiplication operation, we shall have y_0  = \exp x_0 and y_i = (\sum_{j=0}^{i-1} y_j ((i-j)x_{i-j}))/i.

For the last operation of this post, we shall consider the power of a polynomial. Suppose x(h) is a polynomial, we are going to find y(h)=(x(h))^\alpha for any real number \alpha. First, we need to take logarithm on both sides and then differentiate the result with respect to h, y'(h)/y(h) = \alpha x'(h)/x(h) or y'(h) = \alpha x'(h)y(h)/x(h). By exploiting multiplication and division, we will get the coefficient of y(h).

To facilitate these operation, we build a Python module that will handle these operations. We will also write another code to integrate an ODE. This integration code will work in general without any dependencies on the system or on the order of the system.

def integrate(F,y_init,t_init = 0.0 ,tStop = 1.0 ,h = 0.05 ):
    dim = len(y_init)
    y_sol = []
    for i in range(0,dim):
    t_sol = []
    t = t_init

    while t < tStop:
        y = []
        for i in range(0,dim):

        for k in range(0,20):
            dy = F(y)
            for i in range(0,dim):
        n = len(y[0])
        for i in range(0,dim):
            temp = 0.0
            for j in range(0,n):
                temp = temp + y[i][j]*h**j
        t = t + h

    return np.array(t_sol) ,np.transpose(np.array(y_sol))

All the operations above and the last code will be written in a python file so that if we need to use this Taylor method, we can just import it. Let’s take an example to integrate one ODE. We will create another code that specifies the ODE and also imports all the operations above and then numerically integrate it.

from mytaylor import *
import matplotlib.pyplot as plt
import numpy as np
import math as m
#define your ODE here
def fun(y):
    z = subtractpoli(y[0],multiplypoli(y[0],y[0]))
    return [z]
#define your computation parameter here
y_init = [0.5]
t_init = 0
h = 0.1
tStop = 5.0
#integrating ODE
T, Y = integrate(fun,y_init,t_init,tStop,h)
#real solution computation
real_sol = []
for t in T:
	temp = m.exp(t)/(m.exp(t)+1.0)
#plotting the error versus time
real_sol = np.array(real_sol)
error = Y[:,0]-real_sol

In the above code, we try to numerically integrate y' = y(1-y) with initial condition y(0)=0.5. This is the same system we try to integrate in the previous post. I hope you can see the difference between the last code and the code we have shown in the previous post. We really don’t need to consider about Taylor method at all, we just need to write our system in the above code if we want to compute the numerical solution of our code. Notice that we have written all the operations and the integrating code in a file named which is imported in the first line of the above code. In the fifth line, we can write any ODE we want to integrate, however, the way we write our ODE will be slightly different. Due to polynomial operations that we have defined in this post, x+y cannot be written as just x+y but addpoly(x,y). Once we define our ODE, we can just integrate it like in line 15.

Another thing we would like to do is to extend the operation of polynomial. We have not included trigonometry operations on polynomials and et cetera. We would like also to test this Taylor method to a stiff system. Please find the following two files ( and for interested readers if you would like to test yourselves.

How to fold a paper into thirds, a real analysis perspective

February 19, 2016 Leave a comment

Folding a paper into third is useful when you want to mail someone using an envelope. I search around the internet and there are so many ways to do this. So far, I didn’t see the method I am about to explain. I found this method by accident while I am teaching Real Analysis this semester. I am going to prove that this method actually works. Other methods that I found always use Geometry in the proof but I am going to use Real Analysis instead.

The procedure

Please have a look at the following figure. firststep

The above figure is the first step of our method. Take a sheet of paper and let’s call the left side, side A and the right side, side B. First, you need to fold the paper side A as in the second image of the figure above. It doesn’t have to divide the paper equally, you can just fold it anywhere. Once you do that, you undo the fold and you will have a fold mark, which we call it x_0. Next, you need to fold again, but now you need to fold the right side (side B) along the fold mark x_0 as in the second row of the above figure. Now you will have two fold marks, the latter is called y_0. Now take a look at the following figure. secondstep

Now that we have two fold marks (x_0 and y_0), we need to fold side A along the fold mark y_0, as in the first row of the above figure. Undo the fold, you will have the third fold mark (we call it x_1). Next, we fold the side B until it touch the fold mark x_1 and we will have four fold marks, x_0, x_1 and y_0, y_1. Continue the step over and over again and at one stage, at the n-step, x_n will be close to one third of the paper and y_n will be very close to two third of the paper.


Let’s take an example. Suppose in the beginning, let’s fold side A such that we divide the paper equally. Assume the length of a paper is 1. This means x_0=0.5. If we simulate this case, we will get the following table.

n 1 2 3 4 5
x_n 0.5 0.375 0.3475 0.3359375 0.333984375
y_n 0.75 0.6875 0.671875 0.66796875 0.666992188
6 7 8
0.333496094 0.333374023 0.333343506
0.666748047 0.666687012 0.666671753

As we see, that it took approximately 4-8 steps until x_n is closed to one third of a paper or y_n is closed enough to two third of the paper. However, what happens if we choose different initial condition. We simulate this using a number of initial condition. Suppose we use an A4 paper which has length of 29.7 cm. We choose a number of different initial conditions. We can see the results in the following figures. simulation01The x-axis from the above figure is the initial condition and the y-axis is the number of iteration needed until it is closed enough to one third of paper. Since we use an A4 paper, the x-axis ranges from 0 to 29.7 cm.  The tolerance we use in the above figure is 1 mm. In conclusion, we only need to do only maximum four steps until the last fold mark is only 0.1 cm away from one third of the A4 paper. simulation05

We relax the tolerance in the above figure. We use 0.5 cm as the tolerance and the number of iterations is slightly improved. It can be seen that if our first trial is close enough to one third of A4 paper, we only need to do one step.

Mathematical proof

Finally, it comes to prove that this methods should work. mathematically not numerically. First of all, we need to mathematically model the above procedures. Let’s assume that the length of the paper we use is 1. Let’s use the same notation as used in the above procedures. Given x_0 we will get y_0 = (1+x_0)/2. Recursively, we could compute x_n and y_n as follow:

x_n = y_{n-1}/2 and y_n=(1+x_n)/2, as n=1,2, … .

Even though there are two sequences (x_n) and (y_n), we only need to consider (x_n). We could simplify the sequence (x_n) as follow.

x_0 is given and x_n=y_{n-1}/2=((1+x_{n-1})/2)/2=(1+x_{n-1})/4 for n=1,2,\dots.

Lemma 1
When 0<x_0<1/3 (as 1/3<x_0<1), the sequence (x_n) is bounded above (bounded below).

Lemma 2
When 0<x_0<1/3 (as 1/3<x_0<1), the sequence (x_n) is monotonically increasing (decreasing).

Theorem 3
Given 0<x_0<1, the sequence (x_n) converges to 1/3.

Corollary 4
Given 0<x_0<1, the sequence (y_n) converges to 2/3.

The proofs of the above results are given to my students as exercises.

This is the end of this note and the following is the code to produce the above figures.

import math
import numpy as np
import pylab as plt

def f(x):
 return (29.7+x)/2.0

def g(y):
 return y/2.0

def number_of_iter(x,tol,max_iter):
 iter = 0
 er = abs(x-29.7/3)
 if er <= tol: return 1 
 while er > tol and iter < max_iter: 
  iter = iter + 1 
  y = f(x)
  x = g(y)
  er = min(abs(29.7/3-x),abs(2*29.7/3-y))

 return iter

#main code
x = np.arange(0,29.7,0.1)
y = []
tol = 0.5
max_iter = 100

for t in x:
 result = number_of_iter(t,tol,max_iter) 
y = np.array(y)
ax = plt.gca()

How to compute distance between a point and a line

January 27, 2016 Leave a comment

This semester (Even Semester, 2015-2016) I am teaching a new course, that is called Analytic Geometry or Geometry Analytic, both are the same, I think. Don’t get me wrong, the course is not new, it is just I would be teaching this course the first time. When they told me that I was going to be the lecturer of this course, they did not give me a standard, they did not give me a textbook they normally use, or a list of topics that I must cover, perhaps because this course is not a compulsory course. So, I have a freedom, I can choose topics that I want to teach in Analytic Geometry. The first thing I did, was to browse the internet any textbook about Analytic Geometry or any lecture note. In the end, I pick a textbook (Indonesian book) and I choose some topics of my interest to be the material of this course.

Okay, enough for the background, I am sure you don’t want to hear anymore on that. Let’s get back to main point of this note. Long story short, a straight line became one of the topics in my course, and I was interested on how the formula to compute distance between a point and a line is derived.In this case, I only consider two dimensional case and by distance, I mean the shortest distance between such a point and a certain line, which also means the perpendicular distance. If you don’t remember what is the formula, let me recall you.

Consider a straight line l, given by the following equation:

l : ax + by + c=0.

Suppose we have a point P(x_p,y_p), then the distance between the point P and the straight line l is

d = \frac{|ax_p+by_p+c|}{\sqrt{a^2+b^2}}.fig1-crop

There are other proofs on how to derive the above formula, but I really really like the proof I am going to show you below.  I will divide this note into two section. The first section will talk about a straight line and how to get an equation of a straight line. The latter section will derive the formula.

1. A straight line equation

In high school, I think you must know what conditions we need to have in order to obtain a straight line equation. If we have two points in XY-coordinate we can compute the line equation using the following:


If we have a gradient and a point, we can also compute the line equation using the following:


Of course, in a problem, we won’t get this information so easily. We have work a bit more to get either two points or one point and a gradient and then we are able to obtain the equation of the straight line.

Before I teach this course, I can only conclude that if you want to know the equation of a straight line you need to know either:
(i) two points, or
(ii) a point and gradient of the line.
But, actually there is a third condition, and if we know this condition, we can also compute the equation of a straight line. In the third condition, a line is assumed to be the tangent line of a certain circle. Thus, the characteristics we need to know to form a line are the radius of the circle and the angle between the radius and the positif x-axis. See the figure below.fig2-crop

In the figure, we can see that a line can be determined uniquely if the radius of the circle n and the angle \alpha are known. In the first section of this note, we shall derive how to define a line equation given these two conditions.
Suppose we have a straight line, n are \alpha are given. See the figure below. Consider the point P(x,y). We are going to find the relationship of x and yfig3-crop

The radius n, which is |ON|,  can be computed by adding |OM| and |MN|. We shall consider |OM| first. Consider triangle OMQ which is a right triangle at M. We have the relationship:

|OM|=|OQ|\cos \alpha=x \cos \alpha.

Consider another triangle, PM'Q, which is also a right triangle at M'. We have the following relationship

|PM'|=|PQ|\sin \alpha=y \sin \alpha as it can be computed that the angle \angle PQM is also \alpha.

Therefore, we have n=x \cos \alpha + y \sin \alpha, which is the equation of straight line given that n and \alpha is known.

Before we discuss how to derive the formula to compute the distance between a point and a line, I would like to discuss how to find n and \alpha if we know the general equation of a straight line ax+by+c=0. Consider a line equationax+by+c=0, then we move $c$ to the right hand side and multiple both sides with a non zero constant kkax+kby=-kc. We shall choose k such that ka=\cos \alpha and kb=\sin \alpha. Therefore, we have

k = \pm \frac{1}{\sqrt{a^2+b^2}} and

our equation of line becomes:


Here, we have that the right hand side of the above equation is n=\pm(-\frac{c}{\sqrt{a^2+b^2}}), and we choose the positive value to get n. The angle \alpha can also be computed once we determine n.

2. Distance between a point and a line

To compute a perpendicular distance between a point and a line, we shall use the above result. Consider a straight line l:x \cos \alpha+y \sin \alpha = n_1 and a point P in the following figure.fig4-crop


We want to compute d. In order to do that, we need to make another line that is parallel to the line l and passing through point P. This line, because it is parallel to l and, has the following equation:

x \cos \alpha+y \sin \alpha = n_2

Thus the distance between the point P and the line l can be easily computed by considering the absolute difference between n_1 and n_2 as follow:

d = |n_2-n_1|=|x_p \cos \alpha + y_p \sin \alpha - n_1|

As we know from the first section that we can substitute the latter expression into:

d = |x_p \frac{a}{\sqrt{a^2+b^2}}+ y_p\frac{b}{\sqrt{a^2+b^2}}-(-\frac{c}{\sqrt{a^2+b^2}} )|



which is the same as the formula we mentioned in the beginning of our note.

Categories: Teachings Tags: , ,

My first Coursera course

December 3, 2014 Leave a comment

In the middle of this year, I received a Fulbright Visiting Scholar that allowed me to go to Athens, OH, US. I spent four months in Ohio University starting in September, which means that I took a leave in the university I am working. One of my activities while I was in Ohio University was I took a course from Coursera. At that time I was eager to learn and to know python programming language therefore I decided to take the course, An Introduction to Interactive Programming in Python, offered by Rice University taught by the following professors: Joe Warren, Scott Rixner, John Griener, and Stephen Wong.

My first coursera was nothing but really, really good. The class could not definitely be better. The intructors have put so much effort in preparing the class and at the same time they were really enjoyable and fun. I really learned a lot from this class and I recommend everyone to take this class. After nine weeks, I finished the course and proudly said that I got 96.9% with distinction mark.

But what I wanted to tell here is the content of the course. From knowing nothing of Python I now know that the word ‘python’ is originally from the Month Python’s Flying Circus not the reptilia. I also know how useful this new programming language is. Python can be used to build an interactive game, to conduct some scientific computations, to analyse data science and many more. There are already many communities that use Python and they are (still) growing. One more good thing is the fact that it is free. Python works on either Windows, Linux or Mac and the installation on each device is not that difficult. I am using both Windows and Ubuntu. For Windows, I use mainly Python(x,y) and for Ubuntu, I don’t have to do anything as it is already inside. However, in this course, I did not have to use all of these as one of the instructors has built a nice Python web application that is called Codeskulptor. It will allows us to make a python scripts on your web browser so actually you don’t have to install python in your computer.

From the course, I learned to make interactive games. Even though the games I made were not perfect but I think it is playable and fun enough. I learned to make games like rock-paper-scissors-spock-lizzard, number guessing game, stopwatch game, pong, memory, and asteroids. The following links are the python scripts for all of the above games I made during the course. The link will bring you to a codeskulptor website, in which I had already written a python script. You just need to press the play button on the top left of your screen.

1. RPSLS  This game is called rock-paper-scissors-lizzard-spock game. It is an extention of rock-paper-scissors and first appeared in The Big Bang Theory series.

2. Number guessing game This game, as you might guess, is a number guessing game. The computer hide a number between a small number and a big number and you have finite tries to guess what number the computer is hiding.

3. Stopwatch This game will train your reflexes. It will show a stopwatch and you have to press the pause button every whole second.

4. Pong Oh, please tell me you know this game.

5. Memory There are 16 cards facing down, and all of them come in pair. Figure out the pair with the smallest number of tries.

6. Blackjack The blackjack game, yes, it is the blackjack game that you always know.

7. Asteroids Asteroids is an arcade space shooter game and I think I played this game when I was a kid. I played this game using an Atari device.

Other than those games, I made two another python scripts just for fun. The first is a fan and the second is the illustration of Hilbert’s curve. Hope you like it.

Math on the web 2

September 11, 2014 Leave a comment

This is a second edition of Math on the web, in which I try to list mathematical articles around the internet. I found these articles from googling, from social media networks and many more sources. I will write website links that relate to mathematics and its applications that I found from May 2014 until now. I hope you find them interesting because these are really very subjective.

  1. @TopologyFact : Notes on hyperbolic geometry
    The above link will bring you to a kind of ebook about hyperbolic geometry. To be honest, I have not read it. I just downloaded it and it now sits in my computer hard drive. I got this because in case I want to learn about hyperbolic geometry.
  2. is a webpage that (I think) is similar to the (late) google reader. It can bring you the latest information you are interested in and even it can bring you information from social media like Facebook, Google Plus and Twitter. The link above is a paper created by Nick Chater that brings us information about Mathematical Education. I believe the information will be very useful for mathematics educators like me and you.
  3. @approx_normal: A few awesome bumper stickers here
    The link will bring you to various bumper stickers that are very cool when you are mathematicians. I would buy it if there is someone selling these, especially with the Lorrentz Attractor one.
  4. @kdnuggets: Numeric matrix manipulation: cheat sheet for MATLAB, Python NumPy, R, and Julia #DataScience I am a fan of mathematical softwares. I could sit in my office for hours trying to understand new language of mathematical softwares. This link will bring us the cheat sheet of some most popular languanges. It is not a complete cheat sheet though as it is only discussing the basic operation of matrices., which can be very useful for people who just begin to learn the language.
  5. @pickover Teachers, introduce your students to the wonders of Hilbert Curves at this awesome website.
    @pickover is a twitter acount of a mathematician named Cliff Pickover . He is a well known author who has published more than 50 books. Cited from his website, his books explore topics ranging from computers and creativity to art, mathematics, parallel universes, Einstein, time travel, alien life, religion, dimethyltryptamine elves, and the nature of human genius.
    The link above will bring a very introductive article about Hilbert Curve.
Categories: Teachings

Math on the web 1

May 23, 2014 Leave a comment

The idea just came out of the blue. I like mathematics and I am using twitter. I am amazed that there are so many mathematicians using twitter. I am soo fortunate that there are so many mathematics articles around the web that are very useful, interesting and opening our minds. So, why not save and keep those interesting articles (according to me) .  These articles are mathematics articles that I read in the past few months.

1. @MrHonner: Evolutionary game theory in the classroom by @drvinceknight #mathchat #math

@MrHonner is a twitter account owned by a mathematician Patrick Honner. I followed him and at some stage his tweet opened my mind to learn something new in mathematical teaching

2. @MrHonner: “It’s not how big your class is, it’s what you do with it” Interesting take on class size #edchat

Again, this was a tweet from @MrHonner that brought me an article about the class size vs the quality of teaching. Since we are all teacher, I am sure that this article will be of interest.

3. @ISACalculus: Daylight Savings is mathematically illogical. Dilation not translation. Thanks @MrHonner for clearing this up.

This is a light article yet interesting about Daylight Saving. I am now living in Indonesia, a very nice tropical region which does not have Daylight Saving. I once lived in Australia where Daylight Saving occurs every November – March (the other way around from Europe). I find it Daylight Saving is very interesting and I like this article very much.

4. @standupmaths: You need some maths inequalities? This guy has ≥ you’ll ever need:

Very useful article for mathematics students who wants to compete in mathematics olympiad. But let me give a credit to @standupmaths first. This account belongs to Matt Parker who is (of course) a mathematician. And he is also a stand-up comedian. If I get the chance and the universe allows me, I would invite him to my university. Anyway, the title of the article explains a lot. It would give us a summary of inequalities you have ever (or never) heard. So, grab it before the link is dead.

5. I am so sorry that I do not put who is the one tweeted this link cause I have forgotten. However, the link will bring you to an article about fractal. It is a very nice introduction to fractal and you’ll love it the way the author presented the article. Not only did he provide figures and illustrations but also he provided animations and simulations on how to make a fractal shape. 

6. Again I have forgotten who was the one who tweeted/retweeted this link. This is my last article about mathematics on the web. I think it is quite pretty to end this post with this article cause this article is about how math can give you the best job (in terms of salary). The article said in the beginning: “Another day, another reason to get better at math,” which for me, is true.

As a conclusion, I’ll let you read the articles. I am pretty sure I am going to write math on the web 2 next month or after that.

Categories: Teachings