The political events of the 11th Century played a major role in the course of Khayyam's life. The Seljuq Turks were tribes that invaded southwestern Asia in the 11th Century and eventually founded an empire that included Mesopotamia, Syria, Palestine, and most of Iran. The Seljuq occupied the grazing grounds of Khorasan and then, between 1038 and 1040, they conquered all of north-eastern Iran. The Seljuq ruler Toghrïl Beg proclaimed himself sultan at Nishapur in 1038 and entered Baghdad in 1055. It was in this difficult unstable military empire, which also had religious problems as it attempted to establish an orthodox Muslim state, that Khayyam grew up.
Khayyam studied philosophy at Naishapur and one of his fellow students wrote that he was:-
... endowed with sharpness of wit and the highest natural powers ...
However, this was not an empire in which those of learning, even those as learned as Khayyam, found life easy unless they had the support of a ruler at one of the many courts. Even such patronage would not provide too much stability since local politics and the fortunes of the local military regime decided who at any one time held power. Khayyam himself described the difficulties for men of learning during this period in the introduction to his Treatise on Demonstration of Problems of Algebra:- I was unable to devote myself to the learning of this algebra and the continued concentration upon it, because of obstacles in the vagaries of time which hindered me; for we have been deprived of all the people of knowledge save for a group, small in number, with many troubles, whose concern in life is to snatch the opportunity, when time is asleep, to devote themselves meanwhile to the investigation and perfection of a science; for the majority of people who imitate philosophers confuse the true with the false, and they do nothing but deceive and pretend knowledge, and they do not use what they know of the sciences except for base and material purposes; and if they see a certain person seeking for the right and preferring the truth, doing his best to refute the false and untrue and leaving aside hypocrisy and deceit, they make a fool of him and mock him.
However Khayyam was an outstanding mathematician and astronomer and, despite the difficulties which he described in this quote, he did write several works including Problems of Arithmetic, a book on music and one on algebra before he was 25 years old. In 1070 he moved to Samarkand in Uzbekistan which is one of the oldest cities of Central Asia. There Khayyam was supported by Abu Tahir, a prominent jurist of Samarkand, and this allowed him to write his most famous algebra work, Treatise on Demonstration of Problems of Algebra from which we gave the quote above. We shall describe the mathematical contents of this work later in this biography.
Toghril Beg, the founder of the Seljuq dynasty, had made Esfahan the capital of his domains and his grandson Malik-Shah was the ruler of that city from 1073. An invitation was sent to Khayyam from Malik-Shah and from his vizier Nizam al-Mulk asking Khayyam to go to Esfahan to set up an Observatory there. Other leading astronomers were also brought to the Observatory in Esfahan and for 18 years Khayyam led the scientists and produced work of outstanding quality. It was a period of peace during which the political situation allowed Khayyam the opportunity to devote himself entirely to his scholarly work. During this time Khayyam led work on compiling astronomical tables and he also contributed to calendar reform in 1079. Cowell quotes The Calcutta Review No 59:-
When the Malik Shah determined to reform the calendar, Omar was one of the eight learned men employed to do it, the result was the Jalali era (so called from Jalal-ud-din, one of the king's names) - 'a computation of time,' says Gibbon, 'which surpasses the Julian, and approaches the accuracy of the Gregorian style.'
Khayyam measured the length of the year as 365.24219858156 days. Two comments on this result. Firstly it shows an incredible confidence to attempt to give the result to this degree of accuracy. We know now that the length of the year is changing in the sixth decimal place over a person's lifetime. Secondly it is outstandingly accurate. For comparison the length of the year at the end of the 19th century was 365.242196 days, while today it is 365.242190 days.
In 1092 political events ended Khayyam's period of peaceful existence. Malik-Shah died in November of that year, a month after his vizier Nizam al-Mulk had been murdered on the road from Esfahan to Baghdad by the terrorist movement called the Assassins. Malik-Shah's second wife took over as ruler for two years but she had argued with Nizam al-Mulk so now those whom he had supported found that support withdrawn. Funding to run the Observatory ceased and Khayyam's calendar reform was put on hold. Khayyam also came under attack from the orthodox Muslims who felt that Khayyam's questioning mind did not conform to the faith. He wrote in his poem the Rubaiyat :-
Indeed, the Idols I have loved so longHave done my Credit in Men's Eye much Wrong:Have drowned my Honour in a shallow cup,And sold my reputation for a Song.
Despite being out of favour on all sides, Khayyam remained at the Court and tried to regain favour. He wrote a work in which he described former rulers in Iran as men of great honour who had supported public works, science and scholarship.
Malik-Shah's third son Sanjar, who was governor of Khorasan, became the overall ruler of the Seljuq empire in 1118. Sometime after this Khayyam left Esfahan and travelled to Merv (now Mary, Turkmenistan) which Sanjar had made the capital of the Seljuq empire. Sanjar created a great centre of Islamic learning in Merv where Khayyam wrote further works on mathematics.
The paper  by Khayyam is an early work on algebra written before his famous algebra text. In it he considers the problem:-
Find a point on a quadrant of a circle in such manner that when a normal is dropped from the point to one of the bounding radii, the ratio of the normal's length to that of the radius equals the ratio of the segments determined by the foot of the normal.
Khayyam shows that this problem is equivalent to solving a second problem:-
Find a right triangle having the property that the hypotenuse equals the sum of one leg plus the altitude on the hypotenuse.
This problem in turn led Khayyam to solve the cubic equation x3 + 200x = 20x2 + 2000 and he found a positive root of this cubic by considering the intersection of a rectangular hyperbola and a circle. An approximate numerical solution was then found by interpolation in trigonometric tables. Perhaps even more remarkable is the fact that Khayyam states that the solution of this cubic requires the use of conic sections and that it cannot be solved by ruler and compass methods, a result which would not be proved for another 750 years. Khayyam also wrote that he hoped to give a full description of the solution of cubic equations in a later work :-
If the opportunity arises and I can succeed, I shall give all these fourteen forms with all their branches and cases, and how to distinguish whatever is possible or impossible so that a paper, containing elements which are greatly useful in this art will be prepared.
Indeed Khayyam did produce such a work, the Treatise on Demonstration of Problems of Algebra which contained a complete classification of cubic equations with geometric solutions found by means of intersecting conic sections. In fact Khayyam gives an interesting historical account in which he claims that the Greeks had left nothing on the theory of cubic equations. Indeed, as Khayyam writes, the contributions by earlier writers such as al-Mahani and al-Khazin were to translate geometric problems into algebraic equations (something which was essentially impossible before the work of al-Khwarizmi). However, Khayyam himself seems to have been the first to conceive a general theory of cubic equations. Khayyam.
In the science of algebra one encounters problems dependent on certain types of extremely difficult preliminary theorems, whose solution was unsuccessful for most of those who attempted it. As for the Ancients, no work from them dealing with the subject has come down to us; perhaps after having looked for solutions and having examined them, they were unable to fathom their difficulties; or perhaps their investigations did not require such an examination; or finally, their works on this subject, if they existed, have not been translated into our language.
Another achievement in the algebra text is Khayyam's realisation that a cubic equation can have more than one solution. He demonstrated the existence of equations having two solutions, but unfortunately he does not appear to have found that a cubic can have three solutions. He did hope that "arithmetic solutions" might be found one day when he wrote
The "someone else who comes after us" were in fact del Ferro, Tartaglia and Ferrari in the 16th century. Also in his algebra book, Khayyam refers to another work of his which is now lost. In the lost work Khayyam discusses the Pascal triangle but he was not the first to do so since al-Karaji discussed the Pascal triangle before this date. In fact we can be fairly sure that Khayyam used a method of finding nth roots based on the binomial expansion, and therefore on the binomial coefficients. This follows from the following passage in his algebra book:-
In Commentaries on the difficult postulates of Euclid's book Khayyam made a contribution to non-euclidean geometry, although this was not his intention. In trying to prove the parallels postulate he accidentally proved properties of figures in non-euclidean geometries. Khayyam also gave important results on ratios in this book, extending Euclid's work to include the multiplication of ratios. The importance of Khayyam's contribution is that he examined both Euclid's definition of equality of ratios (which was that first proposed by Eudoxus) and the definition of equality of ratios as proposed by earlier Islamic mathematicians such as al-Mahani which was based on continued fractions. Khayyam proved that the two definitions are equivalent. He also posed the question of whether a ratio can be regarded as a number but leaves the question unanswered.
Outside the world of mathematics, Khayyam is best known as a result of Edward Fitzgerald's popular translation in 1859 of nearly 600 short four line poems the Rubaiyat. Khayyam's fame as a poet has caused some to forget his scientific achievements which were much more substantial. Versions of the forms and verses used in the Rubaiyat existed in Persian literature before Khayyam, and only about 120 of the verses can be attributed to him with certainty. Of all the verses, the best known is the following:-
The Moving Finger writes, and, having writ,Moves on: nor all thy Piety nor WitShall lure it back to cancel half a Line,Nor all thy Tears wash out a Word of it.