Skip to content →

neverendingbooks Posts

math2.0-setup : mysql and php+

Last time I wondered whether a set-up like WordPress.com meets FaceBook with add-ons (such as wiki- and latex-support) might be a usable environment for people working in a specific arXiv-topic.

I’ve used WordPressMU and BuddyPress to create such an embryonal environment. At first I thought I’d extend it a bit before going online but I fail to have the energy right now so I might as well make the link available. If you are into math.QA and/or math.RA you are invited to join the experiment. But, please use this site gently as I’ll have to drop it otherwise.

I’ve no desire to maintain this site indefinitely but would welcome others to set up something similar. For this reason I’ll write a couple of posts explaining how you can build it yourself when you’d have a free afternoon and a spare Mac around. Each post should not take you longer than 1 hour. Today, we’ll provide the boring but essential basics : we must get a MySQL-server and a WebServer running. Next time, I’ll take you through the WordPressMU (MU for multi-users) and BuddyPress installation. After that, we’ll add extra functionality.

We will start from a vanilla 10.5.6 installation. We will often need to edit files, so we’d better grab a good, free  texteditor : TextWrangler, drag it to Applications and place it in the Dock. We’ll also type in commands so we want the TerminalApp (to be found in Applcations/Utilities) in the Dock. SystemPreferences and Safari are already in the Dock and as we will need these tools a lot we might rearrange the Dock to look like



From left to right : the Finder, Terminal, Safari, TextWrangler and System Preferences. From now on we will mean by ‘Open …’ that you click on the ‘…’ icon. In the end we want our computer to become a web-server, so we don’t want it to go to sleep. Open SystemPreferences and look for the ‘Energy Saver’-icon, click on the ‘Show details’ button and set the ‘Put the computer to sleep when it is inactive for:’ to Never and unmark the ‘Put the hard disk(s) to sleep when possible’ at the bottom.

We will need to start or stop the WebServer so here’s how that’s done : open SystemPreferences and look for the ‘Sharing’-icon. Marking the ‘Web Sharing’ option is equivalent to starting your webserver (you can verify this by opening Safari and pointing it to http://localhost/ and you should see the default Apache-screen), unmarking it stops the webserver (check this by repeating the previous, now you should get a ‘Safari can’t connect to the server’ message).

All of this was probably trivial to you so let’s do something a bit more advanced : setting up a database-server. OSX doesn’t come with MySql, so we need to download and install it.

MySQL :

Get the latest version : choose the Mac OS X 10.5 (x86)-package and download it (they ask you to register but you can bypass this by clicking on the ‘No thanks, just take me to the downloads’-link). It is a 55.3 Mb file so this may take a couple of minutes. If all goes well this window should pop-up



Click on the mysql-5.0.67-osx10.5-x86.pkg icon and follow the instruction (defaults suffice, you’ll be asked to give your sudo password and in all it will take less than a minute). Repeat this procedure with MySQLStartupItem.pkg. Done!

To verify it, Open Terminal and type this to the prompt

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

You’ll get a scary warning message but type in your sudo-password and the Mysql-server will start. You can access it by typing

/usr/local/mysql/bin/mysql

and type exit to the mysql-prompt to leave.
In all, your interaction with the terminal should look something like this



Clearly, you do not want to type all of this every time, so we will add the mysql-location to our ‘PATH’. To do this, open TextWrangler and add this line to the blank document

export PATH=$PATH:/usr/local/mysql/bin

and save the file as .profile in your home-directory (the one with the ‘House’-icon, usually given your name). You will get a warning that .-files are reserved but go ahead anyway by clicking the use . – button). Now, open Terminal and type this

source ~./profile
echo $PATH

if all went well you should now see the mysql-location at the end of your path. From now on you’ll only have to type

mysql

to the terminal-prompt to open MySql. At the moment the root-user of your mysql has no password which isnt safe so we’d better set one. Open terminal and type

mysqladmin -u root password NEWPASSWORD

where, of course, you replace NEWPASSWORD with your choice (use only letters and numbers). From now on you can access your mysql-server by opening Terminal and typing

mysql -u root -p

and giving your password. Okay, so we’ve established our first goal, we have a working Mysql. Take a break if you need one.

better PHP

Mac 10.5 comes equipped with php5 but unfortunately it isn’t quite up to what we need. So, we need to install a better one and tell the mysql-server and the webserver to use the new one instead of the standard one.

Open Safari and grab the better php-version by going to

http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz

It is a 85.2 Mb file, so have a bit of patience. The file gets unzipped automatically and downloaded in the Downloads-directory. Open Finder and go there. At the moment your Downloads-directory will look like



Doubleclick on the php5-5.2.5-6-beta.tar file and a new directory will be created called php5. We will now move this directory and lay some symbolic links. Open a new Terminal window and type the following commands (and provide your sudo-password when asked)

cd Downloads
sudo mv php5 /usr/local
sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Next, we have to tell the webserver to use this new php-version instead of the old one. This information is contained in the apache-configuration file : httpd.conf. Open TextWrangler and under ‘File’ choose the option ‘Open File by Name’. Type /etc/apache2/httpd.conf in the field that appears. The file will now appear in the main window. Under ‘Search’ choose the ‘Go to Line’ option and fill in 114 and hit the Go To button. The follwing line should now be highlighted

#LoadModule php5_module libexec/apache2/libphp5.so

immediately under it add the following line (TextWrangler will tell you that the file is owned by root and ask you whether you want to open it, click yes and make the changes)

LoadModule php5_module local/php5/libphp5.so

(observe that line 114 is commented out, that is, starts with a #, whereas your added line is not).
Save the file (Textwrangler will ask you to provide the sudo-password).

Next, we will have to tell php to communicate with the mysql-server. Again, open TextWrangler, under ‘File’ choose ‘Open File by Name’ and type in /usr/local/php5/lib/php.ini-recommended. When the file appears, under ‘Search’ choose ‘Go to Line’ and type in 810. It will read

mysql.default_socket =

Change it as follows (that is, add to it)

mysql.default_socket = /var/mysql/mysql.sock

and now choose under ‘File’ the ‘Save as…’ option. In the window change php.ini-recommended to php.ini and click Save. Done!

Testing…

Restart your webserver. Recall that this means: open SystemPreferences, choose ‘Sharing’, unmark ‘Web Server’, wait 5 seconds and then mark it again.

Open TextWranger, make a new Text document containing just one line (remove the white space between the ?-signs and the brackets) :

< ?php phpinfo() ? >

Choose ‘File’ and ‘Save as…’ and in the window that appears navigate to YourHardDisk/Library/WebServer/Documents, name the file ‘test.php’ and click the ‘Save’ button



Finally, open Safari and point it to http://localhost/test.php. Cross your fingers and if you get a screen like the one below treat yourself to something nice!



Leave a Comment

yet another math2.0 proposal

At present, some interesting experiments are going on exploring the potential of web 2.0 for mathematical research, that is, setting up a usable math 2.0 – environment.

The starting point is that math 2.0 should be something like blogs+extras. Most mathematicians are not that interested in the latest ICT-tools, but at least they are slowly getting used to reading blogs, so we should stick to this medium and try to enhance it for online-research.

Michael Nielsen has written a couple of posts on this : an after-dinner talk about doing science online aiming at a mathematics audience, building on an essay on the future of science.

Both posts were influential to Tim Gowers‘ dream of massively collaborative mathematics. He took an interesting problem, laid down a set of 12 rules-of-conduct and invited everyone to contribute. The project is still gaining momentum and Terry Tao is also posting about it on his blog.

Michael Nielsen compared Gowers’ approach to long established practice in the open-source software community.

Another interesting experiment is nLab, a knowledge-wiki set up by the reader-community of the n-category cafe. They describe it as : “In other words: this place is like the library, or alchemist’s laboratory, in the back room of the n-Category Café. You come here to work and go there to chat.
We are hoping to create here a space for presentation and archival storage of collaborative work of encyclopedic, didactic, expositional, but also original nature. This will include, but not be limited to, the subjects being discussed every day in the n-Café.”

Both experiments are working great, aided by the authority-status of the blogger, resp. the popularity of the blog, within the research topic. But, what about topics failing to have a blogger or blog of similar status? Should we all drop our current research-interest and convert to either combinatorics or higher-categories?

History taught us in case of failing authority we’d better settle for ‘manageable anarchy’. So, here’s my math2.0-anarchy-allowed-proposal :

  • per research-topic (say, an arXiv-topic) we’ll set up a seperate online-reasearch-environment
  • anyone interested in that topic is allowed to register and fill-out a profile linking to her list of publications, describe his research interests, her ongoing projects and other trivia
  • some may want to start a blog within the environment or join an already existing one, and should be allowed to do so
  • some may opt just to read blog posts and occasionally comment, and again, should be allowed to do so
  • some may want to set up a research-group to solve a specific problem. they may choose to do this in the open, or as a covert-operation, taking on new members only by invitation
  • some may use the environment mainly for networking or chatting-up with their friends
  • some research-groups may want to start a group-blog or knowledge-wiki to archive their finds
  • surely we’ll be not discussing math in ASCII but in latex
  • anyone will be able to follow specific sub-projects via RSS-feeds
  • anyone can see site-wide activity online, see who’s currently there and chat if they feel the need
  • anyone can do whatever sensible web2.0-thing there is I forgot by age and hence by ignorance

If this seems like a tall order to satisfy, a bit of research will show that we live at the fortunate moment in time when all the basic ingredient are there, freely available, to do just that!

Over the last weeks I’ve wasted too many hours googling for help, reading-up different fora to get it all working, but … somehow succeeded. Here’s a screen-shot of my very-own NSN (for : noncommutative-social-network) :



Please allow me a few more days to tidy things up and then I’ll make the link available so that anyone interested can experiment with it.

But then, I’ve no desire to spend my days web-mastering such a site. Perhaps some of you would like to take this on, provided you’d get it on a silver plate? (that is, without having to spend too much time setting it up).

So. I’ll run a series of posts explaining how to “set-up your own math2.0 environment”. I’m not aiming at the internet-savvy ones (they’ll probably do it a lot more efficiently), but at people like myself, who are interested to investigate web-based possibilities, but need to be told where to find the very basics, such as the location of their httpd.conf file or their php.ini and such.

I’ve zeroed my MacBookPro, re-installed OSX 10.5 from scratch, upgraded it to current 10.5.6 but no extras (say, vanilla 10.5.6). And I’ll guide you from there, in all gory details, with plenty of screen-shots as I would have liked to find them when I tried to set this up.

One Comment

On2 : extending Lenstra’s list

We have seen that John Conway defined a nim-addition and nim-multiplication on the ordinal numbers in such a way that the subfield $[\omega^{\omega^{\omega}}] \simeq \overline{\mathbb{F}}_2 $ is the algebraic closure of the field on two elements. We’ve also seen how to do actual calculations in that field provided we can determine the mystery elements $\alpha_p $, which are the smallest ordinals not being a p-th power of ordinals lesser than $[\omega^{\omega^{k-1}}] $ if $p $ is the $k+1 $-th prime number.

Hendrik Lenstra came up with an effective method to compute these elements $\alpha_p $ requiring a few computations in certain finite fields. I’ll give a rundown of his method and refer to his 1977-paper “On the algebraic closure of two” for full details.

For any ordinal $\alpha < \omega^{\omega^{\omega}} $ define its degree $d(\alpha) $ to be the degree of minimal polynomial for $\alpha $ over $\mathbb{F}_2 = [2] $ and for each prime number $p $ let $f(p) $ be the smallest number $h $ such that $p $ is a divisor of $2^h-1 $ (clearly $f(p) $ is a divisor of $p-1 $).

In the previous post we have already defined ordinals $\kappa_{p^k}=[\omega^{\omega^{k-1}.p^{n-1}}] $ for prime-power indices, but we now need to extend this definition to allow for all indices. So. let $h $ be a natural number, $p $ the smallest prime number dividing $h $ and $q $ the highest power of $p $ dividing $h $. Let $g=[h/q] $, then Lenstra defines

$\kappa_h = \begin{cases} \kappa_q~\text{if q divides}~d(\kappa_q)~\text{ and} \\ \kappa_g + \kappa_q = [\kappa_g + \kappa_q]~\text{otherwise} \end{cases} $

With these notations, the main result asserts the existence of natural numbers $m,m’ $ such that

$\alpha_p = [\kappa_{f(p)} + m] = [\kappa_{f(p)}] + m’ $

Now, assume by induction that we have already determined the mystery numbers $\alpha_r $ for all odd primes $r < p $, then by teh argument of last time we can effectively compute in the field $[\kappa_p] $. In particular, we can compute for every element its multiplicative order $ord(\beta) $ and therefore also its degree $d(\beta) $ which has to be the smallest number $h $ such that $ord(\beta) $ divides $[2^h-1] $.

Then, by the main result we only have to determine the smallest number m such that $\beta = [\kappa_{f(p)} +m] $ is not a p-th power in $\kappa_p $ which is equivalent to the condition that

$\beta^{(2^{d(\beta)}-1)/p} \not= 1 $ if $p $ divides $[2^{d(\beta)}-1] $

All these conditions can be verified within suitable finite fields and hence are effective. In this manner, Lenstra could extend Conway’s calculations (probably using a home-made finite field program running on a slow 1977 machine) :

[tex]\begin{array}{c|c|c} p & f(p) & \alpha_p \\ \hline 3 & 2 & [2] \\ 5 & 4 & [4] \\ 7 & 3 & [\omega]+1 \\ 11 & 10 & [\omega^{\omega}]+1 \\ 13 & 12 & [\omega]+4 \\ 17 & 8 & [16] \\ 19 & 18 & [\omega^3]+4 \\ 23 & 11 & [\omega^{\omega^3}]+1 \\ 29 & 28 & [\omega^{\omega^2}]+4 \\ 31 & 5 & [\omega^{\omega}]+1 \\ 37 & 36 & [\omega^3]+4 \\ 41 & 20 & [\omega^{\omega}]+1 \\ 43 & 14 & [\omega^{\omega^2}]+ 1 \end{array}[/tex]

Right, so let’s try the case $p=47 $. To begin, $f(47)=23 $ whence we have to determine the smallest field containg $\kappa_{23} $. By induction (Lenstra’s tabel) we know already that

$\kappa_{23}^{23} = \kappa_{11} + 1 = [\omega^{\omega^3}]+1 $ and $\kappa_{11}^{11} = \kappa_5 + 1 = [\omega^{\omega}]+1 $ and $\kappa_5^5=[4] $

Because the smallest field containg $4 $ is $[16]=\mathbb{F}_{2^4} $ we have that $\mathbb{F}_2(4,\kappa_5,\kappa_{11}) \simeq \mathbb{F}_{2^{220}} $. We can construct this finite field, together with a generator $a $ of its multiplicative group in Sage via


sage: f1.< a >=GF(2^220)

In this field we have to pinpoint the elements $4,\kappa_5 $ and $\kappa_{11} $. As $4 $ has order $15 $ in $\mathbb{F}_{2^4} $ we know that $\kappa_5 $ has order $75 $. Hence we can take $\kappa_5 = a^{(2^{220}-1)/75} $ and then $4=\kappa_5^5 $.

If we denote $\kappa_5 $ by x5 we can obtain $\kappa_{11} $ as x11 by the following sage-commands


sage: c=x5+1

sage: x11=c.nth_root(11)

It takes about 7 minutes to find x11 on a 2.4 GHz MacBook. Next, we have to set up the field extension determined by $\kappa_{23} $ (which we will call x in sage). This is done as follows


sage: p1.=PolynomialRing(f1)

sage: f=x^23-x11-1

sage: F2=f1.extension(f,'u')

The MacBook needed 8 minutes to set up this field which is isomorphic to $\mathbb{F}_{2^{5060}} $. The relevant number is therefore $n=\frac{2^{5060}-1}{47} $ which is the gruesome

34648162040462867047623719793206539850507437636617898959901744136581<br/>
259144476645069239839415478030722644334257066691823210120548345667203443<br/>
317743531975748823386990680394012962375061822291120459167399032726669613
<br/>
442804392429947890878007964213600720766879334103454250982141991553270171

938532417844211304203805934829097913753132491802446697429102630902307815

301045433019807776921086247690468136447620036910689177286910624860871748

150613285530830034500671245400628768674394130880959338197158054296625733

206509650361461537510912269982522844517989399782602216622257291361930850

885916974186835958466930689748400561295128553674118498999873244045842040

080195019701984054428846798610542372150816780493166669821114184374697446

637066566831036116390063418916814141753876530004881539570659100352197393

997895251223633176404672792711603439161147155163219282934597310848529360

118189507461132290706604796116111868096099527077437183219418195396666836

014856037176421475300935193266597196833361131333604528218621261753883518

667866835204501888103795022437662796445008236823338104580840186181111557

498232520943552183185687638366809541685702608288630073248626226874916669

186372183233071573318563658579214650042598011275864591248749957431967297

975078011358342282941831582626985121760847852546207377440873367589369439

085660784239080183415569559585998884824991911321095149718147110882474280

968166266224151511519773175933506503369761671964823112231808283557885030

984081329986188655169245595411930535264918359325712373064120338963742590

76555755141425

Remains ‘only’ to take x,x+1,etc. to the n-th power and verify which is the first to be unequal to 1. For this it is best to implement the usual powering trick (via digital expression of the exponent) in the field F2, something like


sage: def power(e,n):
...: le=n.bits()
...: v=n.digits()
...: mn=F2(e)
...: out=F2(1)
...: i=0
...: while i< le :
...: if v[i]==1 : out=F2(out_mn)
...: m=F2(mn_mn)
...: mn=F2(m)
...: i=i+1
...: return(out)
...:

then it takes about 20 seconds to verify that power(x,n)=1 but that power(x+1,n) is NOT! That is, we just checked that $\alpha_{47}=\kappa_{11}+1 $.

It turns out that 47 is the hardest nut to crack, the following primes are easier. Here’s the data (if I didn’t make mistakes…)

[tex]\begin{array}{c|c|c} p & f(p) & \alpha_p \\ \hline 47 & 23 & [\omega^{\omega^{7}}]+1 \\ 53 & 52 & [\omega^{\omega^4}]+1 \\ 59 & 58 & [\omega^{\omega^8}]+1 \\ 61 & 60 & [\omega^{\omega}]+[\omega] \\ 67 & 66 & [\omega^{\omega^3}]+[\omega] \end{array}[/tex]

It seems that Magma is substantially better at finite field arithmetic, so if you are lucky enough to have it you’ll have no problem finding $\alpha_p $ for all primes less than 100 by the end of the day. If you do, please drop a comment with the results…

Leave a Comment