Instant Download Python for Scientists (3rd Edition) John M. Stewart PDF All Chapters
Instant Download Python for Scientists (3rd Edition) John M. Stewart PDF All Chapters
https://ebookmass.com
https://ebookmass.com/product/python-for-
scientists-3rd-edition-john-m-stewart/
https://ebookmass.com/product/prototyping-python-dashboards-for-
scientists-and-engineers-padraig-houlahan/
testbankdeal.com
https://ebookmass.com/product/applied-numerical-methods-with-python-
for-engineers-and-scientists-steven-c-chapra/
testbankdeal.com
https://ebookmass.com/product/mathematics-pocket-book-for-engineers-
and-scientists-5th-edition-john-bird/
testbankdeal.com
Statistical Thinking From Scratch: A Primer For Scientists
M. D. Edge
https://ebookmass.com/product/statistical-thinking-from-scratch-a-
primer-for-scientists-m-d-edge/
testbankdeal.com
https://ebookmass.com/product/python-distilled-david-m-beazley/
testbankdeal.com
https://ebookmass.com/product/beginning-programming-with-python-for-
dummies-3rd-edition-john-paul-mueller/
testbankdeal.com
https://ebookmass.com/product/precalculus-mathematics-for-
calculus-8th-edition-james-stewart/
testbankdeal.com
Third Edition
JOHN M . S TE WA RT
University of Cambridge
MI C HAE L MO MM E RT
University of St. Gallen, Switzerland
Shaftesbury Road, Cambridge CB2 8EA, United Kingdom
One Liberty Plaza, 20th Floor, New York, NY 10006, USA
477 Williamstown Road, Port Melbourne, VIC 3207, Australia
314–321, 3rd Floor, Plot 3, Splendor Forum, Jasola District Centre, New Delhi – 110025, India
103 Penang Road, #05–06/07, Visioncrest Commercial, Singapore 238467
www.cambridge.org
Information on this title: www.cambridge.org/9781009014809
DOI: 10.1017/9781009029728
First and Second editions © John M. Stewart 2014, 2017
Third edition © Cambridge University Press & Assessment 2023
This publication is in copyright. Subject to statutory exception and to the provisions
of relevant collective licensing agreements, no reproduction of any part may take
place without the written permission of Cambridge University Press & Assessment.
First published 2014
Second edition 2017
Third edition 2023
Printed in the United Kingdom by CPI Group Ltd, Croydon CR0 4YY
A catalogue record for this publication is available from the British Library
A Cataloging-in-Publication data record for this book is available from the Library of Congress
ISBN 978-1-009-01480-9 Paperback
Additional resources for this publication at www.cambridge.org/9781009014809.
Cambridge University Press & Assessment has no responsibility for the persistence
or accuracy of URLs for external or third-party internet websites referred to in this
publication and does not guarantee that any content on such websites is, or will remain,
accurate or appropriate.
Contents
Preface page xi
1 Introduction 1
1.1 Python for Scientists 1
1.2 Scientific Software 1
1.3 About This Book 4
1.4 References 4
2 About Python 5
2.1 What Is Python? 5
2.1.1 A Brief History of Python 6
2.1.2 The Zen of Python 7
2.2 Installing Python 8
2.2.1 Anaconda and Conda 9
2.2.2 Pip and PyPI 10
2.3 How Python Works 11
2.4 How to Use Python 11
2.4.1 The Python Interpreter 11
2.4.2 IPython and Jupyter 12
2.4.3 Integrated Development Environments 16
2.4.4 Cloud Environments 17
2.5 Where to Find Help? 17
2.6 References 19
3 Basic Python 22
3.1 Typing Python 22
3.2 Objects and Identifiers 23
3.3 Namespaces and Modules 26
3.4 Numbers 28
3.4.1 Integers 28
3.4.2 Real Numbers 28
3.4.3 Booleans 29
3.4.4 Complex Numbers 30
vi Contents
I bought a copy of Python for Scientists at a conference booth in 2016, looking for an
affordable and easily readable textbook for a Python course I was teaching at that time.
I was intrigued by how straightforwardly even complex things were explained in this
book. It was a perfect match for my course and my students, despite my impression that
the book was rather heavily focused on mathematical applications.
It has been five years since the second edition of Python for Scientists was released.
This is a long time in the life cycle of a programming language that is still under active
development. It was definitely time for an update.
Unfortunately, John is no longer with us to provide this update himself. Instead, I was
honored that this task was offered to me, and I could not decline.
Besides updating the Python code examples shown in the book, I took the opportunity
to also update the content of the book with the goal of making it accessible to a broader
audience of scientists, especially those with a quantitative focus in their work. This in-
cludes a more in-depth discussion of numerical mathematics with NumPy (Chapter 4)
and SciPy (Chapter 5), plotting capabilities with Matplotlib (Chapter 6), and, for the
first time, data handling with Pandas (Chapter 8), performance computing with Python
(Chapter 9), and an outline of software development techniques that are useful to scien-
tists (Chapter 10). However, in order to keep the book reasonably short and affordable,
other content, such as the detailed treatment of ordinary and partial differential equa-
tions, had to be significantly shortened or removed altogether – Python packages for
dealing with such problems exist, but their discussion is beyond the scope of this begin-
ner book.
I sincerely hope the third edition of Python for Scientists will be a useful companion on
your long journey to becoming a scientific programmer.
Michael Mommert
St. Gallen, November 2022
1 Introduction
The title of this book is Python for Scientists, but what does that mean? The dictionary
defines “Python” as either (a) a nonvenomous snake from Asia or Saharan Africa or (b)
a computer programming language, and it is the second option that is intended here. By
“scientist,” we mean anyone who uses quantitative models either to obtain conclusions
by processing precollected experimental data or to model potentially observable results
from a more abstract theory, and who asks “what if?” What if I analyze the data in a
different way? What if I change the model?
Given the steady progress in the development of evermore complex experiments that
explore the inner workings of nature and generate vast amounts of data, as well as the
necessity to describe these observations with complex (nonlinear) theoretical models,
the use of computers to answer these questions is mandatory. Luckily, advances in com-
puter hardware and software development mean that immense amounts of data or com-
plex models can be processed at increasingly rapid speeds. It might seem a given that
suitable software will also be available so that the “what if” questions can be answered
readily. However, this turns out not always to be the case. A quick pragmatic reason
is that while there is a huge market for hardware improvements, scientists form a very
small fraction of it and so there is little financial incentive to improve scientific soft-
ware. But for scientists, specialized, yet versatile, software tools are key to unraveling
complex problems.
Since wages and taxes are recurrent expenditures, the company needs to issue frequent
charged-for updates and improvements (the Danegeld effect).
Open-source software, on the other hand, is available for free. It is usually developed
by computer-literate individuals, often working for universities or similar organizations,
who provide the service for their colleagues. It is distributed subject to anti-copyright
licenses, which give nobody the right to copyright it or to use it for commercial gain.
Conventional economics might suggest that the gamut of open-source software should
be inferior to its proprietary counterpart, or else the commercial organizations would
lose their market. As we shall see, this is not necessarily the case.
Next we need to differentiate between two different types of scientific software. The eas-
iest approach to extracting insight from data or modeling observations utilizes prebuilt
software tools, which we refer to as “scientific software tools.” Proprietary examples
include software tools and packages like Matlab, Mathematica, IDL, Tableau, or even
Excel and open-source equivalents like R, Octave, SciLab, and LibreOffice. Some of
these tools provide graphical user interfaces (GUIs) enabling the user to interact with
the software in an efficient and intuitive way. Typically, such tools work well for stan-
dard tasks, but they do offer only a limited degree of flexibility, making it hard if not
impossible to adapt these packages to solve some task they were not designed for. Other
software tools provide more flexibility through their own idiosyncratic programming
language in which problems are entered into a user interface. After a coherent group
of statements, often just an individual statement, has been typed, the software writes
equivalent core language code and compiles it on the fly. Thus errors and/or results can
be reported back to the user immediately. Such tools are called “interpreters” as they in-
terpret code on the fly, thus offering a higher degree of flexibility compared to software
tools with shiny GUIs.
On a more basic level, the aforementioned software tools are implemented in a pro-
gramming language, which is a somewhat limited subset of human language in which
sequences of instructions are written, usually by humans, to be read and understood by
computers. The most common languages are capable of expressing very sophisticated
mathematical concepts, albeit often with a steep learning curve. Although a myriad of
programming languages exist, only a handful have been widely accepted and adopted
for scientific applications. Historically, this includes C and Fortran, as well as their de-
scendants. In the case of these so-called compiled languages, compilers translate code
written by humans into machine code that can be optimized for speed and then pro-
cessed. As such, they are rather like Formula 1 racing cars. The best of them are capable
of breathtakingly fast performance, but driving them is not intuitive and requires a great
deal of training and experience. This experience is additionally complicated by the fact
that compilers for the same language are not necessarily compatible and need to be sup-
plemented by large libraries to provide functionality for seemingly basic functionality.
Since all scientific software tools are built upon compiled programming languages,
why not simply write your own tools? Well, a racing car is not usually the best choice
for a trip to the supermarket, where speed is not of paramount importance. Similarly,
1.2 Scientific Software 3
compiled languages are not always ideal for quickly trying out new ideas or writing
short scripts to support you in your daily work. Thus, for the intended readers of this
book, the direct use of compilers is likely to be unattractive, unless their use is manda-
tory. We therefore look at the other type of programming language, the so-called in-
terpreted languages, which include the previously mentioned scientific tools based on
interpreters. Interpreted languages lack the speed of compiled languages, but they typi-
cally are much more intuitive and easier to learn.
Let us summarize our position. There are prebuilt software tools, some of which are
proprietary and some of which are open-source software, that provide various degrees
of flexibility (interpreters typically offer more flexibility than tools that feature GUIs)
and usually focus on specific tasks. On a more basic level, there are traditional compiled
languages for numerics that are very general, very fast, rather difficult to learn, and do
not interact readily with graphical or algebraic processes. Finally, there are interpreted
languages that are typically much easier to learn than compiled languages and offer a
large degree of flexibility but are less performant.
So, what properties should an ideal scientific software have? A short list might contain:
a mature programming language that is both easy to understand and has extensive
expressive ability,
integration of algebraic, numerical, and graphical functions, and the option to import
functionality from an almost endless list of supplemental libraries,
the ability to generate numerical algorithms running with speeds within an order of
magnitude of the fastest of those generated by compiled languages,
an extensive range of textbooks from which the curious reader can develop greater
understanding of the concepts,
You might have guessed it: we are talking about Python here.
The purpose of this intentionally short book is to introduce the Python programming
language and to provide an overview of scientifically relevant packages and how they
can be utilized. This book is written for first-semester students and faculty members,
graduate students and emeriti, high-school students and post-docs – or simply for ev-
eryone who is interested in using Python for scientific analysis.
However, this book by no means claims to be a complete introduction to Python. We
leave the comprehensive treatment of Python and all its details to others who have
done this with great success (see, e.g., Lutz, 2013). We have quite deliberately pre-
ferred brevity and simplicity over encyclopedic coverage in order to get the inquisitive
reader up and running as soon as possible.
Furthermore, this book will not serve as the “Numerical Recipes for Python,” meaning
that we will not explain methods and algorithms in detail: we will simply showcase how
they can be used and applied to scientific problems. For an in-depth discussion of these
algorithms, we refer to the real Numerical Recipes – Press et al. (2007) and all following
releases that were adapted to different programming languages – as well as other works.
Given the dynamic environment of software development, details on specific packages
are best retrieved from online documentation and reference websites. We will provide
references, links, and pointers in order to guide interested readers to the appropriate
places. In order to enable an easy entry into the world of Python, we provide all code
snippets presented in this book in the form of Jupyter Notebooks on the CoCalc cloud
computing platform. These Notebooks can be accessed, run, and modified online for a
more interactive learning experience.
We aim to leave the reader with a well-founded framework to handle many basic, and
not so basic, tasks, as well as the skill set to find their own way in the world of scientific
programming and Python.
1.4 References
Print Resources
Lutz, Mark. Learning Python: Powerful Object-Oriented Programming. O’Reilly Me-
dia, 2013.
Press, William H, et al. Numerical Recipes: The Art of Scientific Computing. 3rd ed.,
Cambridge University Press, 2007.
2 About Python
Python is currently the most popular programming language among scientists and other
programmers. There are a number of reasons leading to its popularity and fame, es-
pecially among younger researchers. This chapter introduces the Python programming
language and provides an overview on how to install and use the language most effi-
ciently.
Based on various recent reports and statistics, Python is currently the most popular
programming language among researchers and professional software developers for a
wide range of applications and problems. This popularity largely stems from the ease
of learning Python, as well as the availability of a large number of add-on packages
that supplement basic Python and provide easy access to tasks that would otherwise be
cumbersome to implement.
Visit https://ebookmass.com
now to explore a rich
collection of eBooks and enjoy
exciting offers!
6 About Python
But there is also a downside: Python is an interpreted language, which makes it slower
than compiled languages. However, Python provides some remedies for this issue as we
will see in Chapter 9.
Van Rossum is considered the principal author of Python and has played a central role
in its development until 2018. Since 2001, the Python Software Foundation, a nonprofit
organization focusing on the development of the core Python distribution, managing
intellectual rights, and organizing developer conferences, has played an increasingly
important role in the project. Major design decisions within the project are made by a
five-person steering council and documented in Python Enhancement Protocols (PEPs).
PEPs mainly discuss technical proposals and decisions, but we will briefly look at two
PEPs that directly affect users: the Zen of Python (PEP 20, Section 2.1.2) and the Python
Style Guide (PEP 8, Section 3.13).
We would also like to note that in 2012, NumFOCUS was founded as a nonprofit or-
ganization that supports the development of a wide range of scientific Python packages
including, but not limited to, NumPy (see Chapter 4), SciPy (see Chapter 5), Matplotlib
(see Chapter 6), SymPy (see Chapter 7), Pandas (see Chapter 8), Project Jupyter, and
IPython. The support through NumFOCUS for these projects includes funding that is
based on donations to NumFOCUS; for most of these open-source projects, donations
are their only source of funding.
2.1 What Is Python? 7
One detail we have skipped so far is why Van Rossum named his new programming
language after a snake. Well, he did not. Python is actually named after the BBC comedy
TV show Monty Python’s Flying Circus, of which Van Rossum is a huge fan. In case you
were wondering, this is also the reason why the words “spam” and “eggs” are oftentimes
used as metasyntactic variables in Python example code in a reference to their famous
“Spam” sketch from 1970.
Please note that these guidelines focus on the design of the Python programming lan-
guage, not necessarily the design of code written in Python. Nevertheless, you are free to
follow these guidelines when writing your own code to create truly pythonic code. The
term pythonic is often used within the Python community to refer to code that follows
the guiding principles mentioned here.
Random documents with unrelated
content Scribd suggests to you:
his disposal the poet enjoyed a rare, almost a unique advantage.
The energy and softness of the Arabian language, its melodious
character, the abundance and variety of its metaphors, render it
peculiarly available as the vehicle of poetic sentiment. There is
perhaps no idiom which lends itself with such facility to the
construction of rhyme; for its very prose is frequently musical. The
researches of modern philology have brought to the notice of Europe
the complexity and perfection of its grammatical construction, the
richness of its vocabulary, its boundless scope and graceful imagery.
Most appropriately did the old philosopher, Mohammed-al-Damiri,
referring to the native eloquence and exuberant diction of his
countrymen, exclaim: “Wisdom hath lighted on three things,—the
brain of the Franks, the hands of the Chinese, and the tongues of the
Arabs.”
The poetry of the Arabs is even more obscure in its origin than the
primitive history of their race. Without the assistance of writing, no
literature, however popular, can maintain its integrity for even a
single generation. Even the phenomenal memory of that people—a
gift so universal as not to elicit comment among them, and which
was strengthened by the daily rehearsal of favorite compositions—
could only imperfectly supply the place of permanent and authentic
records. The matter of the Arabian poems was therefore constantly
changing, while the subjects and versification remained the same.
Their form was generally that of the dramatic pastoral; sometimes
the elegiac ode, which offered an opportunity for the enumeration of
the virtues of the deceased and, incidentally, of the achievements of
his tribe, was adopted. The genius of the pre-Islamitic poet never
attempted the epic, which so often profits by the inexhaustible
resources of the fabulous; and, although surrounded by an
atmosphere eminently favorable to the inspiration of such
productions, it does not seem to have had an adequate conception
of them. Its representations exhibited to the enraptured listener the
stirring events of his adventurous life, which his pride taught him to
regard as vastly superior, in all that promotes the dignity of humanity,
to the corrupt and inert existence of civilization. The universal
possession of the poetic faculty was one of the peculiarities of the
Arab nation. Old and young alike seemed gifted with it. The rules of
prosody, and even the simplest canons of metrical composition, were
unknown. Yet such was the instinctive perception of rhythmical
correctness, that the versification of the most humble was
characterized by propriety and elegance, qualities which tended to
enhance the fierce enthusiasm, the sublimity of thought, the touching
pathos, the burning passion, which pervade the noble poems of the
Desert. Many of the latter bear a striking resemblance to the Song of
Solomon; some are remarkable for their rhapsodies; others for their
weighty and sententious wisdom; others again for their sparkling wit
and pointed epigrams. The seven poems called Moallakat, “The
Suspended,”—a word of doubtful significance so far as its relation to
these productions is concerned—have always been considered the
masterpieces of the ancient Arabs, and form the principal source
from which our ideas of their attainments in the art of poetry must be
derived. Popular credulity ascribed the name of these compositions
to their presumed suspension in the Kaaba as evidence of the
triumphs of their authors over all competitors; the more rational
conjecture, however, connects the title of Moallakat with a necklace
or pendant, of which each poem formed a jewel, a figurative mode of
designating literary works among Orientals, and one especially
affected by poets and historians. The entire body of tradition,
combined with facts accumulated by subsequent writers of every
race and creed, does not afford such a thorough insight into the
public and domestic life, the prevailing sentiments and prejudices,
the habits and customs of the inhabitants of the Peninsula, as do the
Moallakat. They enable us partially to reconstruct the political and
religious systems of the early Arabians, and to establish, by
comparison, their identity with the conditions of modern existence, in
localities where the sword of Islam has never been able to
exterminate the detested practice of idolatry. They place before us,
in all its impressiveness, the silent majesty of the Desert, its dazzling
sky, its waves of quivering vapor, its interminable waste of sand; they
pass in review the indolent life of the camp, varied only by a
nocturnal alarm or by some daring intrigue; they relate the exciting
scenes of the foray; they delineate with erotic freedom the charms of
the lovely Bedouin maid; they describe the fate of the female
prisoner whose captivity was often the result of artifice or barter; they
rehearse the midnight march under the starry firmament, which in
the florid language of the East “appeared like the folds of a silken
sash variously decked with gems.” Nor is the excellence of the
Moallakat confined to mere description. The proud boast of exploits
not unworthy of the Age of Chivalry, which, in fact, received its
inspiration from this source; the sacred duties of a lavish hospitality;
the rare qualities of a favorite horse or camel; the absorbing passion
of love, its perils and its pleasures; the Herculean feats of virile
manhood,—these were the chosen themes of the Arab poet. His
verses abound in moral precepts and philosophical apothegms,
conveying lessons of worldly wisdom which recall, in both their
phraseology and their profound acquaintance with human nature, the
Suras of the Koran and the Proverbs of Solomon. In addition to
maxims of a moral tone, scattered through these productions, they
exhibit, on the other hand, much that is repulsive, cruel, and
barbarous. Epicureanism is, however, the prominent characteristic of
the Moallakat, as, indeed, it is of all primitive Arabic poems which
have descended to us. The charms of wine and women, and an
indulgence in the pleasures of the banquet to the extreme limit of
bacchanalian revelry, are everywhere celebrated with a license
worthy of the grossest couplets of Catullus and Martial. In the
relation of scenes of intrigue and midnight assignation, often laid in
the camp of a hostile tribe, where discovery would have led to instant
death, the adventurous spirit of the lover is deemed worthy to rank
with that which sustains the hero in the front of battle. The most
fulsome adulation characterizes the homage tendered by the ardent
lover to the object of his idolatry. Modern fastidiousness would not
tolerate the descriptions given by the poet of the physical perfections
of his lady-love in all their circumstantial details; though translations
exist, they are mere paraphrases; and the voluptuous images of the
poet’s fancy still remain discreetly hidden in the obscurity of the
original idiom.
There is much similarity and repetition in Arab poetry, which the
interpolations and substitutions inevitable among a people
dependent for the preservation of their literature upon oral tradition
will hardly account for.
The existence of the Bedouin was bounded by a narrow horizon,
the Desert was his world. Its familiar objects and localities, which
never changed; the deeds which they recalled; the hopes which they
inspired; the memory of ancestral renown with which they were
associated, suggested the topics of his song. The haughtiness which
was one of his most offensive characteristics, and forbade his
permanent alliance or his intermarriage with other races,
strengthened the feelings of reserve which had been a national
peculiarity for countless generations. His ideas, his aspirations, his
joys, his sorrows, evoked by the monotonous circumstances of his
environment, were little subject to deviation during the course of
centuries. While his religion was a compound of all degrees of
fetichism, idolatry, and astral worship, his poetry was original, pure,
artless, and natural. His aptitude for versification was disclosed by
the most trivial occurrences of life. A rhyming stanza, which set forth
an appropriate sentiment, was often the reply to an ordinary
question. Where allusion was made to an historical incident, the
speaker was often challenged to confirm his statement by the
recitation of an original verse, or by an apt poetical quotation, as the
most reliable authority. The quick perception of the Arab was shown
by his ability to finish instantly a couplet corresponding in sense and
measure with a line repeated by a competitor. Its general similarity to
all others renders the assignment of any Arabic poem to a certain
epoch impossible, for the natural taste has never varied, and a
composition that was popular three hundred years before the Hegira
would be equally acceptable to-day to the mountain tribes of Central
Arabia.
In the opening lines of most Arabic poems, and in those of the
Moallakat especially, there is a dearth of individuality, and a common
resemblance which would almost suggest that they had been written
by the same person. The purity of style which characterizes the latter
was, however, universally admitted; they were the recognized
standards of grammatical correctness; they were consulted
whenever a dispute arose concerning the meaning of a word or the
construction of a sentence in later authors was in doubt; and among
Mohammedans the authority of those Pagan compositions was
never entirely superseded even by that of the Koran, whose
sublimity of thought and elegance of diction were reverently ascribed
to the direct inspiration of God.
We owe the survival of the Moallakat to the capricious taste of
some self-appointed critic, who selected them from a number of
poems with which he was familiar; and, through his arbitrary choice,
we are deprived of the opportunity of forming an opinion of the
others which his rejection has tacitly pronounced inferior. We know
nothing of his qualifications for such a task, and are even ignorant of
his name; but, from the remaining fragments of these productions,
we may safely conclude that some of them, at least, were as fully
entitled to preservation as the seven more fortunate ones which
have descended to posterity.
It is a remarkable fact that no Arabic poem shows traces of
Hebrew influence or contains ideas borrowed from either the
Scriptures or the Talmud. The wealth and political power of the Jews;
their intimate association with the nomadic tribes of the Peninsula; a
close similarity of traditions, customs, and language, produced no
perceptible effect upon the prehistoric literature of the Arabs. The
Hebrews of Arabia, nevertheless, had their poets, whose
productions, on the other hand, exhibit a marked coincidence of
thought and style with those of their Arab kinsmen. Their sentiments
are lofty and admirable, their language pure, and their merit, while
inferior to that of the Moallakat, is still far from contemptible. The
Book of Job, which has no apparent connection with the rest of the
Scriptures, has been pronounced by competent critics a translation
of an Arabic poem.
Improvisation, a talent possessed only by those endowed with
unusual readiness of perception, a lively imagination, and an
inexhaustible command of language, was practised with great
success by the itinerant poets of Arabia. From their auditors, a
couplet happily applied, by the inspiration of the moment, to some
well-known event, elicited far more applause than efforts, however
meritorious, which had cost days of arduous labor. This art of
extemporaneous composition, which, when thoroughly developed,
implies the possession of extraordinary mental ability, carried into
Europe by the Moslems, and long employed by the troubadours, now
survives only among the lowest class of the Italian peasantry. It is, in
our day, most difficult to determine what degree of authenticity may
properly be ascribed to the poetry of the ancient Arabs, none of
which ascends to a higher antiquity than two hundred years before
the Hegira. The unreliability of oral tradition, the variety of dialects,
the frequent substitutions of modern phraseology, the bad faith,
interpolations, and mistakes of unscrupulous commentators, the
corruption and suppression of passages through tribal prejudice—all
of these causes have had their share in effecting the gradual
deterioration of the grand and stirring poems of Arabia.
It is impossible for us to appreciate the influence exercised by
those who had attained to eminence in the poetic art over their
imaginative and passionate countrymen. The Arab bard was without
exception the most important personage of his tribe. Wealth, rank,
beauty, personal popularity, military distinction alike paid tribute to his
genius. To his talent for improvisation and versification, he often
united the threefold character of statesman, warrior, and knight-
errant, and thus became the model of his associates, the idol of the
fair sex, and the terror of his enemies, who were as sensitive to the
poisoned shafts of his satire as to the keenness of his sword. The
most famous of these rhyming paladins, and the author of one of the
Moallakat, whose life and achievements have been made the subject
of a romance which approaches more nearly to the nature of an epic
than any other production in the Arabic language, was Antar. By
instinct and training a Bedouin, he was, however, of Arab blood only
on his father’s side, his mother having been an Abyssinian slave.
According to the custom of his country, he shared her lot until his
bravery in battle induced his father to emancipate him. His amatory
exploits, as well as his daring enterprises against the enemy, made
him the admiration of the fiery Arabian youth. It was the regret of
Mohammed, often expressed, that he had never seen this knight-
errant of the Desert, who shrank from no danger, however appalling,
who redressed the wrongs of woman, who restored the property of
the plundered, and whose favorite maxim was, “Bear not malice, for
of malice good never came.”
The unbridled license of the Arabian poet offers a curious
commentary on national manners. The most exalted dignity, the
sacred attributes of the gods, the pride of opulence, the delicacy of
the sex, were not exempt from the attacks of his venom and
sarcasm. He exposed with relentless severity the frailties of the wife
and daughters of the sheik. He boasted of his own intrigues with a
shameless audacity which, under more refined social conditions,
could only be atoned for with blood. The immunity he enjoyed was
one of the prerogatives of his calling. A certain sacredness of
character was believed to attach to the latter by reason of the
demoniac possession to which was popularly attributed the
inspiration of the poetic faculty. His verses abounded in chivalrous
sentiments, but uniformly ignored the claims of religion to the
veneration of mankind. No beautiful mythology, like that of ancient
Greece, was at hand to prompt the efforts of his muse. The maxims
of the luxurious Epicurean were those that exerted the greatest
power over his imagination and his life. An idea may be formed of
the influence of poetry. on the public mind when we remember that
the Koreish in vain attempted to bribe the pagan bard Ascha to
deliver a panegyric on Mohammed at the commencement of the
latter’s career, and, unable to secure his compliance, succeeded
with much difficulty in purchasing his neutrality and silence at the
expense of a hundred camels. The Prophet was so sensitive to the
keen thrusts of the satirist, that when Mecca was captured and a
general amnesty proclaimed, one of the four unfortunates whom he
expressly excluded from this act of clemency was an obscure poet,
Habbar-Ibn-Aswad by name, who had published a lampoon against
him. The Arabian bard, like his literary descendant the troubadour,
was attended by minstrels who chanted his verses, often to the
accompaniment of musical instruments. The latter vocation,
regarded as degrading by the Bedouin, was always exercised by a
slave.
Islamism, while in other directions it zealously promoted the
intellectual development of its adherents, fell like a blight upon the
poetic taste and genius of Arabia. The dreams of the poet
disappeared before the stern fanaticism of the soldier, who had no
time for rhapsodies, and cared for nothing save indulgence in rapine,
the acquisition of empire, and the extension of the Faith.
It is now generally admitted that the literary contests said to have
taken place during the annual fair at Okhad, where, from poems read
before an immense concourse, the one to be suspended in the
Kaaba was selected, are apocryphal. Tribes of vagrant robbers who
passed ten months of the year in plundering their neighbors would
hardly consent to spend the other two in an orderly assembly,
composed mainly of their enemies, in determining by a popular vote
the comparative merit of their respective poets. The settlement of
such rival claims for intellectual precedency by the voice of the
people implies a degree of culture and critical acumen certainly not
possessed by the Arabs of that age. This idle tale has doubtless
been suggested by the literary exhibitions of the Olympian games,
and is perhaps indebted to the imagination of some garrulous and
mendacious Greek for its origin. It is, however, unquestionable that
the poet, as well as the story-teller—that other important personage
in the East—was in high favor at all the fairs and assemblies of
Arabia. The mixed multitude which, impelled by motives partly
mercenary, partly religious, collected on these occasions, and in its
hours of leisure listened to the verses of the poet, constantly
promoted his inspiration and refined his lays by the hope of
applause, the fear of censure, the collision with foreigners, and the
powerful influence of tribal emulation.
The later history of the Arabs is decked with all the gorgeous
imagery of the East. The fascinations of romance invest and
embellish it. With the commonplace facts incident to the various
stages of national progress are interwoven narratives of indisputable
truth, but which, in their demands upon human credulity, almost
surpass the fabulous legends of chivalry or the enchanting tales of
Scheherezade. The primitive life of the Arabian people previous to
the advent of Mohammed offered no indication of their extraordinary
capability for improvement. Commercial intercourse with other
nations for ages had, however, enlarged their experience, expanded
their faculties, and aroused their ambition. The caravan winding
amidst the lonely sand-hills of the Desert—the precursor of those
great expeditions which subsequently interchanged the commodities
of Asia Minor, Egypt, Andalusia, and India—was also the more
important agent of science, of refinement, of civilization. It increased
the sum of geographical and historical knowledge. It familiarized the
trader and his customers with the manners, the laws, the social
systems, the mechanical skill, the arts, and the inventions of the
most enterprising nations of the globe. These associations assisted
in no small degree to generate the practical utility which, the most
important feature of Arab learning, afterwards conferred such
substantial blessings on mankind. The phenomenal advance of the
race to maturity, impossible without previous preparation, was
stimulated by perpetual wars and excitement. Less than one
hundred and twenty years intervened between the vagabondage and
ignorance of the Desert and the stability and intellectual culture of
the great Abbaside and Ommeyade capitals. The career of the Arab
was too rapid to be permanent. In four generations it had covered
the ground ordinarily traversed in twenty. Its delusive splendor
concealed the decay which was coincident with the era of its
greatest prosperity. The same causes which facilitated the
foundation and advancement of his power and culture were active
during their decline, and contributed to their ultimate destruction.
The statement may appear paradoxical, in view of the
acknowledged influence of mercantile associations upon the
faculties of the human mind; but a certain degree of isolation seems
to be necessary, at least in tropical and semi-tropical regions, for the
complete development of the arts of civilization; and these arts have
usually attained their highest perfection among nations which inhabit
peninsulas. Egypt and China, whose reliance was entirely upon their
own resources, were the most exclusive of nations in the ancient
world, as were Mexico and Peru in the modern. The vast majority of
the populations of India, Japan, and Spain had but little intercourse
with those outside their boundaries, which were defended by stormy
and mysterious seas. In no other countries have the powers of the
human intellect, in the creation of all that is grand and imposing, of
all that is beautiful, of all that is artistic, of all that contributes to the
benefit, the cultivation, and the material improvement of mankind,
been manifested as in Greece and Italy. And Arabia, although denied
by Nature the advantages of soil and climate enjoyed by more
favored lands, yet possessed what, in the crisis of her fate, rendered
her superior to all her adversaries,—a race of bold and hardy
warriors inured to hardship by the privations of an abstemious life,
and by habit and inclination capable of the most arduous and
desperate enterprises. Their experience with the surrounding
effeminate nations had taught them not only the weakness of the
latter, but also how their coveted wealth might be obtained; and at a
propitious moment, under the guidance of an impassioned
enthusiast, a horde of outlaws, driven from their homes by their
scandalized neighbors, became the nucleus of victorious armies the
fame of whose gallantry filled the world. And yet, while glorying in the
deeds of martial heroism which insured the establishment and
maintenance of her Prophet’s faith, she was conscious of the
instability of an empire sustained by arms alone, and labored to raise
upon more substantial and enduring foundations the splendid fabric
of her greatness. The same fervid impulse which prompted and
carried to a successful issue the conquest or extermination of those
designated by the comprehensive term of infidel was able to adapt
itself with singular facility to all the conditions of peace, and to enable
the posterity of the half-naked banditti that swarmed around the
banner of Mohammed to accomplish results worthy of the most
exalted genius, and in every department of knowledge to ascend to
the highest rank of those celebrated for their literary and scientific
attainments in the most polished communities of Asia and Europe.
CHAPTER II
THE RISE, PROGRESS, AND INFLUENCE OF ISLAM
614–712