Table Of ContentMathematica by Example
Mathematica by
Example
Fifth Edition
Martha L. Abell
Georgia Southern University, Statesboro, USA
James P. Braselton
Georgia Southern University, Statesboro, USA
AcademicPressisanimprintofElsevier
125LondonWall,LondonEC2Y5AS,UnitedKingdom
525BStreet,Suite1800,SanDiego,CA92101-4495,UnitedStates
50HampshireStreet,5thFloor,Cambridge,MA02139,UnitedStates
TheBoulevard,LangfordLane,Kidlington,OxfordOX51GB,UnitedKingdom
Copyright©2017ElsevierInc.Allrightsreserved.
Nopartofthispublicationmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,
includingphotocopying,recording,oranyinformationstorageandretrievalsystem,withoutpermissioninwritingfromthe
publisher.Detailsonhowtoseekpermission,furtherinformationaboutthePublisher’spermissionspoliciesandour
arrangementswithorganizationssuchastheCopyrightClearanceCenterandtheCopyrightLicensingAgency,canbe
foundatourwebsite:www.elsevier.com/permissions.
ThisbookandtheindividualcontributionscontainedinitareprotectedundercopyrightbythePublisher(otherthanasmay
benotedherein).
Notices
Knowledgeandbestpracticeinthisfieldareconstantlychanging.Asnewresearchandexperiencebroadenour
understanding,changesinresearchmethods,professionalpractices,ormedicaltreatmentmaybecomenecessary.
Practitionersandresearchersmustalwaysrelyontheirownexperienceandknowledgeinevaluatingandusingany
information,methods,compounds,orexperimentsdescribedherein.Inusingsuchinformationormethodstheyshouldbe
mindfuloftheirownsafetyandthesafetyofothers,includingpartiesforwhomtheyhaveaprofessionalresponsibility.
Tothefullestextentofthelaw,neitherthePublishernortheauthors,contributors,oreditors,assumeanyliabilityforany
injuryand/ordamagetopersonsorpropertyasamatterofproductsliability,negligenceorotherwise,orfromanyuseor
operationofanymethods,products,instructions,orideascontainedinthematerialherein.
LibraryofCongressCataloging-in-PublicationData
AcatalogrecordforthisbookisavailablefromtheLibraryofCongress
BritishLibraryCataloguing-in-PublicationData
AcataloguerecordforthisbookisavailablefromtheBritishLibrary
ISBN:978-0-12-812481-9
ForinformationonallAcademicPresspublications
visitourwebsiteathttps://www.elsevier.com/books-and-journals
Publisher:KateyBirtcher
AcquisitionEditor:GrahamNisbet
EditorialProjectManager:SusanIkeda
ProductionProjectManager:PaulPrasadChandramohan
Designer:MarkRogers
TypesetbyVTeX
Preface
MathematicabyExamplebridgesthegapthatexistsbetweentheveryelementaryhandbooks
availableon Mathematicaand those reference books written for the advanced Mathematica
users.MathematicabyExampleisanappropriatereferenceforallusersofMathematicaand,
in particular, for beginning users like students, instructors, engineers, business people, and
other professionals first learning to use Mathematica. Mathematica by Example introduces
theverybasiccommandsandincludestypicalexamplesofapplicationsofthesecommands.
In addition, the text also includes commands useful in areas such as calculus, linear alge-
bra, business mathematics, ordinary and partial differential equations, and graphics. In all
cases,however,examplesfollowtheintroductionofnewcommands.Readersfromthemost
elementarytoadvancedlevelswillfindthattherangeoftopicscoveredaddressestheirneeds.
TakingadvantageofVersion11ofMathematica,MathematicabyExample,FifthEdition,
introduces the fundamental concepts of Mathematica to solve typical problems of interest
tostudents,instructors,andscientists.TheFifthEditionisanextensiverevisionofthetext.
FeaturesthatmakeMathematicabyExample,FifthEdition,aseasytouseasareferenceand
asusefulaspossibleforthebeginnerincludethefollowing.
1. Version 11 Compatibility. All examples illustrated in Mathematica by Example, Fifth
Edition,werecompletedusingVersion11ofMathematica.Althoughmanycomputations
cancontinuetobecarriedoutwithearlierversionsofMathematica,wehavetakenadvan-
tageofthenewfeaturesinVersion11asmuchaspossible.
2. Applications. New applications, many of which are documented by references, from a
varietyoffields,especiallybiology,physics,andengineering,areincludedthroughoutthe
text.EspeciallynoticethenewexamplesregardingseriesinChapter3andmanipulation
ofphotographsinChapters2,4,and5.
3. DetailedTableofContents.Thetableofcontentsincludesallchapter,section,andsub-
sectionheadings.Alongwiththecomprehensiveindex,wehopethatuserswillbeableto
locateinformationquicklyandeasily.
4. Additionalexamples.WehaveconsiderablyexpandedthetopicsinChapters1through6.
Theresultsshouldbemoreusefultoinstructors,students,businesspeople,engineers,and
otherprofessionalsusingMathematicaonavarietyofplatforms.
5. ComprehensiveIndex.Intheindex,mathematicalexamplesandapplicationsarelisted
by topic, or name, as well as commands along with frequently used options: particular
mathematicalexamplesaswellasexamplesillustratinghowtousefrequentlyusedcom-
mands are easy to locate. In addition, commands in the index are cross-referenced with
frequentlyusedoptions.Functionsavailableinthevariouspackagesarecross-referenced
bothbypackageandalphabetically.
6. As technology has changed, so has the publication of a book. When Mathematica by
Example was first published in 1992, it was published as a single color book. Conse-
quently,atthattime,itwasimportanttousevariousgraylevelsinplotstohelpdistinguish
them. Now, many of you will download an electronic copy of the text and print it on a
high-resolution color printer with high-quality paper. The result will be outstanding. To
illustratetheuseofcolor,wehavechosenfromvariousuniversitiesandcollegesthrough-
out the United States. We tried to use the colors from at least one university or college
ineachstate.Sometimesthiswasdifficulttodobecauseobtainingthecolorcodesfrom
somecollegeswaseasierthanfromothers.Ofcourse,intheprintversionofthetext,all
imageswillstillbeinvariouslevelsofgray.
ix
x Preface
WebeganMathematicabyExamplein1990andthefirsteditionwaspublishedin1991.
Backthen,wewereontopoftheworldusingMacintoshIIcx’swith8megsofRAMand40
megharddrives.Wetriedtochooseexamplesthatwethoughtwouldberelevanttobeginning
users–typicallyinthecontextofmathematicsencounteredintheundergraduatecurriculum.
ThoseexamplescouldalsobecarriedoutbyMathematicainatimelymanneronacomputer
aspowerfulasaMacintoshIIcx.
WhenworkingontheFifthedition,weareonthetopoftheworldwithiMacswithdual
Intelprocessorscompletewith8gigsofRAMand1or2Terabyteharddrives.Nowweare
working with machines with more memory than we can comprehend and so fast we can’t
believethatcomputerswillbefasterbuttheywillalmostcertainlybenearlyobsoletebythe
timeyouarereadingthis.TheexamplespresentedinMathematicabyExamplecontinuetobe
theonesthatwethinkaremostsimilartotheproblemsencounteredbybeginningusersand
arepresentedinthecontextofsomeonefamiliarwithmathematicstypicallyencounteredby
undergraduates. However, for this Fifth edition of Mathematica by Example we have taken
theopportunitytoexpandonseveralofourfavoriteexamplesbecausethemachinesnowhave
thespeedandpowertoexplorethemingreaterdetail.
OtherimprovementstotheFiftheditioninclude:
1. InChapter3,wehaveincreasedthenumberofexamplesrelatingtoapplicationsofseries,
particularlydiscussing“howisπ approximatedaccuratelynow?”
2. Chapter4,IntroductiontoListsandTables,containsseveralexamplesillustratingvarious
techniquesofhowtoquicklycreateplotsofbifurcationdiagrams,Juliasets,andtheMan-
delbrotsetwithnewMathematicafunctionsthatmakevisualizingthesesetsremarkably
easy.
3. InChapter6,wehavetakenadvantageoftheManipulatefunctiontoillustrateavariety
of situations and expand on many examples throughout the chapter. For example, see
Example6.13foracomparisonofsolutionsofnonlinearequationstotheircorresponding
linearapproximations.
4. We have included references that we find particularly interesting in the Bibliogra-
phy, even if they are not specific Mathematica-related texts. A comprehensive list of
Mathematica-relatedpublicationscanbefoundattheWolframwebsite.
http://store.wolfram.com/catalog/books/
Also,besuretoinvestigate,use,andsupportWolfram’sMathWorld–simplyanamazing
webresourceformathematics,Mathematica,andotherinformation.
http://store.wolfram.com/catalog/books/
MarthaL.Abell
JamesP.Braselton
Statesboro,GA,USA
June,2017
Chapter 1
Getting Started
1.1 INTRODUCTION TO MATHEMATICA
Mathematica,firstreleasedin1988byWolframResearch,Inc.,
http://www.wolfram.com/,
is a system for doing mathematicson a computer.Mathematicacombinessymbolicmanip-
ulation,numericalmathematics,outstandinggraphics,andasophisticatedprogramminglan-
guage.Becauseofitsversatility,Mathematicahasestablisheditselfasthecomputeralgebra
system of choice for many computer users. Among the over 1,000,000 users of Mathemat-
ica, 28% are engineers, 21% are computer scientists, 20% are physical scientists, 12% are
mathematical scientists, and 12% are business, social, and life scientists. Two-thirds of the
usersareinindustryandgovernmentwithasmall(8%)butgrowingnumberofstudentusers.
However, due to its special nature and sophistication, beginning users need to be aware of
thespecialsyntaxrequiredtomakeMathematicaperforminthewayintended.Youwillfind
thatcalculationsandsequencesofcalculationsmostfrequentlyusedbybeginningusersare
discussedindetailalongwithmanytypicalexamples.Inaddition,thecomprehensiveindex
not only lists a variety of topics but also cross-references commands with frequently used
options. Mathematica By Example serves as a valuable tool and reference to the beginning
userofMathematicaaswellastothemoresophisticateduser,withspecializedneeds.
Forinformation,includingpurchasinginformation,aboutMathematicacontact:
CorporateHeadquarters:
WolframResearch,Inc.
100TradeCenterDrive
Champaign,IL61820
USA
telephone:217-398-0700
fax:217-398-0747
email:info@wolfram.com
web:http://www.wolfram.com
Europe:
WolframResearchEuropeLtd.
10BlenheimOfficePark
LowerRoad,LongHanborough
OxfordshireOX88LN
UnitedKingdom
telephone:+44-(0)1993-883400
fax:+44-(0)1993-883800
email:info-europe@wolfram.com
Asia:
WolframResearchAsiaLtd.
IzumiBuilding8F
3-2-15Misaki-cho
Chiyoda-ku,Tokyo101
Japan
MathematicabyExample.http://dx.doi.org/10.1016/B978-0-12-812481-9.00001-6
Copyright©2017ElsevierInc.Allrightsreserved. 1
2 MathematicabyExample
telephone:+81-(0)3-5276-0506
fax:+81-(0)3-5276-0509
email:info-asia@wolfram.com
ANoteRegardingDifferentVersionsofMathematica
WiththereleaseofVersion10.4ofMathematica,manynewfunctionsandfeatureshavebeen
addedtoMathematica.WeencourageusersofearlierversionsofMathematicatoupdateto
Version11assoonastheycan.AllexamplesinMathematicaByExample,fifthedition,were
completedwithVersion11.Inmostcases,thesameresultswillbeobtainedifyouareusing
Version10.4orlater,althoughtheappearanceofyourresultswillalmostcertainlydifferfrom
thatpresentedhere.However,particularfeaturesofVersion10.4areusedandinthosecases,
of course, these features are not available in earlier versions. If you are using an earlier or
laterversionofMathematica,yourresultsmaynotappearinaformidenticaltothosefound
in this book: some commands found in Version 11 are not available in earlier versions of
Mathematica; in later versions some commands will certainly be changed, new commands
added,andobsoletecommandsremoved.Fordetailsregardingthesechanges,pleasereferto
the Documentation Center. You can determine the version of Mathematica you are using
during a given Mathematica session by entering either the command $Versionor the com-
mand$VersionNumber.Inthistext,weassumethatMathematicahasbeencorrectlyinstalled
onthecomputeryouareusing.IfyouneedtoinstallMathematicaonyourcomputer,please
refertothedocumentationthatcamewiththeMathematicasoftwarepackage.
On-linehelpforupgradingolderversionsofMathematicaandinstallingnewversionsof
MathematicaisavailableattheWolframResearch,Inc.website:
http://www.wolfram.com/.
DetailsregardingwhatisdifferentinMathematica11frompreviousversionsofMathe-
maticacanbefoundat
http://www.wolfram.com/mathematica/new-in-11/?source=frontpage-stripe.
GettingStarted Chapter | 1 3
Also,whenyougototheWolframDocumentationcenter(underHelpintheMathematica
menu) you can choose Wolfram Documentation to see the major differences. Also, the
upperright handcorner of the mainhelp pagefor eachfunctionwilltell youif it is new in
Version11orhasbeenupdatedinVersion11.
1.1.1 Getting Started with Mathematica
We begin by introducing the essentials of Mathematica. The examples presented are taken
fromalgebra,trigonometry,andcalculustopicsthatmostreadersarefamiliarwithtoassist
youinbecomingacquaintedwiththeMathematicacomputeralgebrasystem.
WeassumethatMathematicahasbeencorrectlyinstalledonthecomputeryouareusing.
IfyouneedtoinstallMathematicaonyourcomputer,pleaserefertothedocumentationthat
camewiththeMathematicasoftwarepackage.
Start Mathematica on your computer system. Using Windows or Macintosh mouse or
keyboardcommands,starttheMathematicaprogrambyselectingtheMathematicaiconoran
existing Mathematica document (or notebook), and then clicking, double-clicking or right-
clickingandselectingOpenontheicon.
IfyoustartMathematicabyselectingtheMathematicaicon,Mathematica’sstartupwin-
dow,“welcomescreen,”isdisplayed,asillustratedinthefollowingscreenshot.
From the startup window, you can perform a variety of actions such as creating a
new notebook. For example, selecting New Document generates a new Mathematica note-
book.
4 MathematicabyExample
Mathematica’sonlinehelpfacilitiesarespectacular.Forbeginningusers,oneofthemore
convenientfeaturesarethevariousPalettesthatareavailable.ThePalettesprovideavariety
of fill-in-the blank templates to perform a wide variety of action. To access a Palette go to
theMathematicamenu,selectPalettesandthenselectagivenPalette.Thefollowingscreen
shotsshowtheBasicMathAssistantandClassroomAssistantpalettes.
IfyougofurtherintothesubmenuandselectOther...,youwillfindtheAlgebraicMa-
ThestandardMathematica
nipulationpalette,aslightlydifferentBasicMathInputpalettefromthatmentionedabove,
palettesaresummarizedin
Fig.1.5. andtheBasicTypesettingpalette.