### Archive

Archive for the ‘i will do these’ Category

## Heidelberg Laurate Forum 2016

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.

## My first try creating a bash script

I am a ubuntu user, but sometimes I also use windows, mainly because my computer in the office is using windows. So, I use both ubuntu and windows. Even, my laptop has both windows and ubuntu. I tried to get rid of windows once, and installed wine to use windows application in my ubuntu. But it runs very slowly and it’s killing me and in the end, I came back to reinstall windows. I mainly use ubuntu for my research. The softwares I use for my research are auto, python, dstool, latex, xfig which run smoothly in ubuntu, even though python and latex can also be installed and run smoothly on windows machine. On the other hand, I use windows to do some regular activities such as browsing the internet, watching movies, checking my email, creating an office documents etc. All of which can be done in ubuntu as well. But there are activities that I must use windows, I sometimes need to use matlab and sometimes I like to play a game that only runs in windows. These two things are the main reason I still come back to use windows. Recently, I learn python so I am now trying to less use matlab.

That is just a background and my main point here is about bash scripting. After a few years using ubuntu, I have not created any bash script. Today, finally I learn to create one script. I created a script to automate my boring routine. When I write a paper, I need some illustrations. I mostly use xfig to create some mathematical images and to be able to use $\LaTeX$ in the figure I need to convert it to an eps file. The produced eps file will be then converted to a pdf file as it is perfectly compatible to my pdflatex command. But before that, I need to crop the resulted pdf file in order to remove white space around the image. Suppose the name of my xfig file is spam.fig. I then write a series of command.

figtex2eps spam.fig
ps2pdf spam.eps
pdfcrop spam.pdf


I want to write a script that do all the above automatically. Thus I created the following script.

#!/bin/bash
# Converts a .fig-file (xfig file) to a .eps-file by using a built-in function figtex2eps
# and then convert it to a .pdf file by using a built-in function ps2pdf
# and finally convert it to a cropped pdf file by using a built-in function pdfcrop
#
# ivanky saputra https://ivanky.wordpress.com
#
# credit to :
# $/home/abel/c/berland/etc/cvsrepository/figtex2eps/prog/figtex2eps$
# $ps2pdf in ubuntu$
# $pdfcrop in ubuntu$
echo "We are going to change the following $1.fig to a cropped pdf file" function quit { exit } if [$1 == ""];
then
echo "no files given";
quit
else
echo "Processing $1.fig............"; figtex2eps$1.fig
ps2pdf $1.eps pdfcrop$1.pdf
echo "Done";
fi


As someone has said that it is better to share your code and data openly as we as human are idiots and will make mistakes, please give me any suggestion to improve mine.

## Liapunov exponent computation

Liapunov exponent method is one of the clever ways to investigate a certain dynamical system to be chaotic. In this post, I shall try to compute Liapunov exponent of one famous discrete dynamical system, i.e. the logistic map. After this, I shall try to compute the Liapunov exponent of a continuous dynamical system.

Actually, I write this post because I want to know how to numerically compute the Liapunov exponent. I often read a book or a website such as wolfram.alpha that shows the Liapunov exponent but it didn’t explain how to get this numerically. After I am able to post this post, and when I forget how to compute this exponent, I’d know where to look.

Suppose we have an initial condition $x_0$ and a nearby initial point $x_0 + \delta_0$, where $\delta_0$ is an initial difference between initial points, which by the way will be extremely small. These two nearby points will be iterated by some map. Let $\delta_n$ be the difference between these two points after n iterations. Consider the following equation

(1) …  $|\delta_n| =|\delta_0 |e^{n \lambda}$.

The coefficient $\lambda$ is called the Liapunov exponent. We want to compute this coefficient. Note that $\delta_n = f^n(x_0)-f^n(x_0+\delta_0)$, where $f$ is the given map. Taking logarithm of (1), we get

(2) … $\lambda = \frac{1}{n} \ln \left|\frac{\delta_n}{\delta_0}\right|=\frac{1}{n} \ln \left|\frac{f^n(x_0)-f^n(x_0+\delta_0)}{\delta_0}\right|=\frac{1}{n} \ln \left|{(f^n)'(x_0)}\right|$

as $\delta_0 \to 0$. The term inside the logarithm can be simplified by using the chain rule: $(f^n)'(x_0) = f'(x_{n-1}) f'(x_{n-2}) \dots f'(x_0)$. Thus (2) becomes

(3) … $\lambda = \frac{1}{n} \sum_{i=0}^{n-1} \ln |f'(x_i)|$.

When $n \rightarrow \infty$, $\lambda$ is defined as the Liapunov exponent. When this exponent is positive, it is a sign of a chaotic attractor.

Let us consider the logistic map that was in my previous post here. Let us fix the parameter value r. Starting at a random initial point, we will iterate the initial point until it reaches the steady state (which will be a fixed point, periodic or aperiodic), say 300 iterates. Now we compute a large number iterates, say 10000 and compute (3) starting from the 301st point. Repeat this procedure for the next r. Then we plot the Liapunov exponent with respect to r. We shall find a figure as follows.

As we can see from the above figure. The map is chaotic in some values of parameter between 3.5 to 4, in which the Liapunov exponent is positive.

The code to produce the above figure is the following

tic; %to compute how long is the computation clear;clc; %clear screem and clear all the previous variables a = 3:0.001:4; %parameter of the logistic map N = 300; %number of iterations until it is stable N1 = 10000; %number of iterations to compute the Liapunov exponent y = zeros(length(a),1); %declares variable for Liapunov exponents for i=1:length(a) x(1) = rand; %random initial conditions% for j = 2:N x(j) = a(i)*x(j-1)*(1-x(j-1)); end sum = 0; for j = 1:N1 x(N+j) = a(i)*x(N+j-1)*(1-x(N+j-1)); sum = sum + log(abs(a(i)-2*a(i)*x(N+j))); end y(i) = sum/10000; fprintf('%d %d\n',i,length(a)); end plot(a,0); hold on; plot(a,y); %plot Liapunov exponent against parameter toc; %display how long computation is clear

## My first logistic bifurcation curve and a bit more

I don’t know since when, but I desperately want to learn how do I make a logistic bifurcation curve. And now, I finally able to create one. I do not want to forget this ability therefore I post this post, just in case I forget.

Logistic map is one of discrete dynamical systems, represented in the following:

$x_{n+1} = \mu x_n (1-x_n)$.

It is basically a recursive sequence. It looks simple but it is highly not.When $\mu \in [0,4]$ the sequence generated will always be inside the interval [0,4].More specifically, when $\mu =2$, the sequence converges to a point. When $\mu$ is varied, does the solution still converge to some point?

In fact, when we vary $\mu$ past 3 we have the situation that is best explained through the following figure:

The figure is saying when $\mu$ is just past 3, the sequence is no longer converging to a point. This phenomena is called a period-doubling, as the sequence now tends to alternatingly approaching two points. However, this is the code to create the above figure in Matlab.

 clear; clc; a = 3:0.005:4;  %interval of parameter x0 = 0.5;       %initial condition N=500;          %number of iterations x(1) = x0;      %the first entry is the initial condition %computation of the orbit figure(3);hold on; for i=1:length(a) for j=2:N x(j) = a(i)*x(j-1)*(1-x(j-1)); end y = x(301:end); plot(a(i),y); end hold off clear

Okay, the fitst task is done. Let us now learn how to make a movie in Matlab. I choose the topic ‘coweb’ as an example. Coweb arises in our topic, which is a discrete dynamical system.

Here is the video

The coweb created in the above movie uses $\mu=3.9$. This exactly where the chaotic dynamic occurs. Therefore, we do not see any pattern there. The iteration that I used is only 90. However, we already see that the sequence makes such a complicated figure.

The code to create such a video is the following.

clc;clear; myu = 3.9; %initial parameter maxiter = 90; %maximum iteration xo = 0.4; %initial condition aviobj = avifile ( 'logistik2.avi', 'fps', 3 );%create a file logistik2.avi x = 0:0.01:1; %range of x data y1 = myu.*x.*(1-x); %range of y data to graph y=myu(x-x^2) y2 = x; %range for y data to graph y=x figure(1);hold on; %open figure window and hold on axis([0 1.1 0 1.1]) % set the y and x axis plot(x,y1); %plot the graph of y=myu(x-x^2) plot(x,y2); %plot the graph of y=x frame = getframe ( gca ); %command 1 to store what is inside figure 1 aviobj = addframe ( aviobj, frame ); %command 2 xbaru = myu.*xo.*(1-xo); z2 = 0:0.01:xbaru; z1 = xo; plot(z1,z2); frame = getframe ( gca ); aviobj = addframe ( aviobj, frame ); fprintf('the fixed point is %f',(myu-1)/myu); for i=2:maxiter if(xbaru > xo) y1 = xo:0.01:xbaru; else y1 = xbaru:0.01:xo; end y2 = xbaru; plot(y1,y2); frame = getframe ( gca ); aviobj = addframe ( aviobj, frame ); xo = xbaru; xbaru = myu.*xo.*(1-xo); if(xbaru > xo) y1 = xo:0.01:xbaru; else y1 = xbaru:0.01:xo; end y2 = xo; plot(y2,y1); frame = getframe ( gca ); aviobj = addframe ( aviobj, frame ); end hold off; H = (myu-1)/myu; fprintf('please press any key \n'); aviobj = close ( aviobj ); %pause; %close all;

However, I really really want to learn how to convert this avi video produced by Matlab to a gif image format. So if anyone know how do I do this please let me know.