Python for Mathematics. The Python Series

Оглавление⌄
Preface xvSection I OverviewChapter 1 ■ Introduction....31.1 WHO IS THIS BOOK FOR?....31.1.1 How is this book different from similar books?....41.2 WHAT IS IN THIS BOOK?....61.2.1 How is this book organised?....61.2.2 How to use this book?....71.2.3 How is coded is played in this book?....71.3 WHAT IS NOT THIS BOOK?....9Section II Tools for MathematicsChapter 2 ■ Using Notebooks....132.1 INTRODUCTION....132.2 TUTORIAL....132.2.1 Installation....132.2.2 Starting a Jupyter notebook server....142.2.3 Creating a new notebook....142.2.4 Organising your files....142.2.5 Writing some basic Python code....172.2.6 Writing markdown....202.2.7 Saving your notebook to a different format....202.3 HOWTO....212.3.1 Install Anaconda....212.3.2 Start a Jupyter notebook server....212.3.3 Create a new notebook....212.3.4 Find/open a notebook....212.3.5 Run Python code....212.3.6 Carry out basic arithmetic operations....222.3.7 Write markdown....222.3.8 Write basic LaTeX....222.3.9 Save the output in a different format....232.4 EXERCISES....242.5 FURTHER INFORMATION....242.5.1 Why use anaconda?....242.5.2 Why use Jupyter?....242.5.3 Why can I not double click on a Jupyter notebook file?....252.5.4 Where can I find keyboard shortcuts for using Jupyter....252.5.5 What is markdown?....252.5.6 What is LaTeX?....252.5.7 Can I use \( and \) instead of $ for LATEX?....262.5.8 What is a mark up language?....26Chapter 3 ■ Algebra....273.1 INTRODUCTION....273.2 TUTORIAL....273.3 HOWTO....333.3.1 Createasymbolicnumericvalue....333.3.2 Getthenumericalvalueofasymbolicexpression....343.3.3 Factoranexpression....353.3.4 Expandanexpression....353.3.5 Simplifyanexpression....363.3.6 Solveanequation....363.3.7 Substituteavalueintoanexpression....383.4 EXERCISES....383.5 FURTHERINFORMATION....393.5.1 Whyissomecodeinseparatelibraries?....393.5.2 WhydoIneedtousesympy?....393.5.3 WhydoIsometimessee from sympyimport*?....403.5.4 Howtoextractasolutionfromtheoutputof sympy.solveset?....423.5.5 WhydoIsometimessee import sympyassym?....44Chapter 4 ■ Calculus....454.1 TUTORIAL....454.2 HOWTO....504.2.1 Calculatethederivativeofanexpression....504.2.2 Calculatetheindefiniteintegralofanexpression....514.2.3 Calculatethedefiniteintegralofanexpression....514.2.4 Use ∞....524.2.5 Calculatelimitsofanexpression....524.3 EXERCISES....534.4 FURTHERINFORMATION....534.4.1 Howcanyouplotafunction....53Chapter 5 ■ Matrices....565.1 TUTORIAL....565.2 HOWTO....595.2.1 Createamatrix....595.2.2 Calculatethedeterminantofamatrix....605.2.3 Calculatetheinverseofamatrix....605.2.4 Multiplymatricesbyascalar....615.2.5 Addmatricestogether....615.2.6 Multiplymatricestogether....625.2.7 Createavector....625.2.8 Solvealinearsystem....625.3 EXERCISES....635.4 FURTHERINFORMATION....645.4.1 Whydoesthisbooknotdiscusscommentingofcode?....645.4.2 Whyuse @ for matrixmultiplicationandnot *?....645.4.3 IsNumpyalibrarythatcanbeusedforlinearalgebra?....65Chapter 6 ■ Combinatorics....666.1 TUTORIAL....666.2 HOWTO....706.2.1 Createatuple....706.2.2 Howtoaccessparticularelementsinatuple....706.2.3 Createbooleanvariables....706.2.4 Createaniterablewithagivennumberofitems....736.2.5 Createpermutationsofagivensetofelements....736.2.6 Createcombinationsofagivensetofelements....746.2.7 Summingitemsinaniterable....756.2.8 Directlycompute n!....766.2.9 Directlycomputeni766.2.10 Directlycompute nPi....776.3 EXERCISES....776.4 FURTHERINFORMATION....786.4.1 Arethereotherwaystoaccesselementsintuples?....786.4.2 Whydo range, itertools.permutations, anditertools.combinations not directlygivetheelements?....786.4.3 Howdoesthesummationnotation correspondtothecode?78x ■ ContentsChapter 7 ■ Probability....807.1 TUTORIAL....807.2 HOWTO....877.2.1 Createalist....877.2.2 Defineafunction....897.2.3 Callafunction....897.2.4 Runcodebasedonacondition....907.2.5 Createalistusingalistcomprehension....927.2.6 Summingitemsinalist....937.2.7 Samplefromaniterable....947.2.8 Samplearandomnumber....957.2.9 Reproducerandomevents....957.3 EXERCISES....967.4 FURTHERINFORMATION....977.4.1 WhatisthedifferencebetweenaPythonlistandaPythontuple?977.4.2 Whydoesthesumofbooleanscountthe Trues?....977.4.3 Whatisthedifferencebetween print and return?....987.4.4 HowdoesPythonsamplerandomness?....997.4.5 Whatisthedifferencebetweenadocstringandacomment....99Chapter 8 ■ Sequences....1028.1 TUTORIAL....1028.2 HOWTO....1048.2.1 Defineafunctionusingrecursion....1048.3 EXERCISES....1058.4 FURTHERINFORMATION....1068.4.1 Whatarethedifferencesbetweenrecursionanditeration?....1068.4.2 Whatiscaching?....108Chapter 9 ■ Statistics....1109.1 TUTORIAL....1109.2 HOWTO....1189.2.1 Calculatemeasuresofspreadandtendency....1189.2.2 Calculatethesamplecovariance....1229.2.3 CalculatethePearsoncorrelationcoefficient....1239.2.4 Fitalineofbestfit....1239.2.5 Createaninstanceofthenormaldistribution....1249.2.6 Usethecumulativedistributionfunctionofanormaldistribution1259.2.7 Usetheinversecumulativedistributionfunctionofanormaldistribution....1259.3 EXERCISES....126Contents ■ xi9.4 FURTHERINFORMATION....1299.4.1 Whatisthedifferencebetweenthesampleandthepopulationvarianceandstandarddeviation?....1299.4.2 Howtoplotalineofbestfit?....1309.4.3 WhatotherstatisticstoolsexistinPython?....1319.4.4 Whatisthedifferencebetweenmachinelearningandstatistics?131Chapter 10 ■ DifferentialEquations....13210.1 TUTORIAL....13210.2 HOWTO....13410.2.1 Createasymbolicfunction....13410.2.2 Createadifferentialequation....13510.2.3 Obtainthegeneralsolutionofadifferentialequation....13610.2.4 Obtaintheparticularsolutionofadifferentialequation....13710.3 EXERCISES....13710.4 FURTHERINFORMATION....13810.4.1 Howtosolveasystemofdifferentialequations?....13810.4.2 Howtosolvedifferentialequationsnumerically?....139Section III Building ToolsChapter 11 ■ Variables,ConditionalsandLoops....14511.1 TUTORIAL....14511.2 HOWTO....14811.2.1 Defineanintegervariable....14811.2.2 Defineafloatvariable....14911.2.3 Defineastringvariable....14911.2.4 Defineabooleanvariable....15011.2.5 Checkthetypeofavariable....15011.2.6 Manipulatenumericvariables....15111.2.7 Includevariablesinstrings....15211.2.8 Combinecollectionsofbooleanvariables....15311.2.9 Runcode if a conditionholds....15311.2.10 Repeatcode for a givensetofvariables....15411.2.11 Repeatcode while a givenconditionholds....15511.2.12 Iterateoverpairsofitemsfromtwoiterables....15611.2.13 Iterateoverandindexitemsfromaniterable....15611.3 EXERCISES....15711.4 FURTHERINFORMATION....15811.4.1 WhycanInotonlyusea while loop?....15811.4.2 WhyshouldInotcheckifabooleanisequalto True or False....159xii ■ ContentsChapter 12 ■ Functions andDataStructures....16112.1 TUTORIAL....16112.2 HOWTO....16412.2.1 Defineafunction....16412.2.2 Writeadocstring....16412.2.3 Createatuple....16512.2.4 Createalist....16512.2.5 Createalistusingalistcomprehension....16512.2.6 Combinelists....16512.2.7 Appendanelementtoalist....16612.2.8 Removeanelementfromalist....16612.2.9 Sortalist....16712.2.10 Createasortedlistfromaniterable....16712.2.11 Accessanelementofaniterable....16812.2.12 Findtheindexofanelementinaniterable....16812.2.13 Accessanelementofaniterableusingnegativeindexing....16812.2.14 Sliceaniterable....16912.2.15 Findthenumberofelementsinaniterable....16912.2.16 Createaset....17012.2.17 Dosetoperations....17012.2.18 Createhashtables....17112.2.19 Accesselementinahashtable....17212.2.20 Iterateoverkeysinahashtable....17312.2.21 Iterateovervaluesinahashtable....17312.2.22 Iterateoverpairsofkeysandvalueinahashtable....17312.3 EXERCISES....17412.4 FURTHERINFORMATION....17512.4.1 Whatformatscanbeusedtowriteadocstring?....17512.4.2 Aretheretoolsavailabletoassistwithwritingdocstrings?17512.4.3 Apartfromremovingduplicatesandsetoperationswhataretheadvantagesofusing set?....175Chapter 13 ■ Object-OrientedProgramming....17613.1 TUTORIAL....17613.2 HOWTO....18113.2.1 Defineaclass....18113.2.2 Createaninstanceoftheclass....18113.2.3 Createanattribute....18213.2.4 Createandcallamethod....18313.2.5 Howtocreateandcallmagicmethods....18413.2.6 Useinheritance....186Contents ■ xiii13.3 EXERCISES....18713.4 FURTHERINFORMATION....18813.4.1 Howtopronouncethedoubleunderscore?....18813.4.2 Whatisthe self variablefor?....18813.4.3 Whyuse CamelCase for classesbut snake case for functions?19013.4.4 Whatisthedifferencebetweenamethodandafunction?....190Chapter 14 ■ Using aCommandLineandanEditor....19114.1 TUTORIAL....19114.2 HOWTO....19614.2.1 Navigatedirectoriesusingthecommandline....19614.2.2 Createanewdirectoryusingthecommandline....19714.2.3 Seethecontentsofadirectoryinthecommandline....19714.2.4 RunPythoncodeinafile....19814.2.5 RunPythoncodewithoutusingafileorJupyter....19814.2.6 InstallVScodeplugins....19814.3 EXERCISES....19914.4 FURTHERINFORMATION....19914.4.1 Whydoyouneedtousethe print function withaneditor?19914.4.2 CanyouuseaPythonplugintorunmycodefrominsidemyeditor?19914.4.3 CanIopenaJupyternotebookinsideVScode?....20014.4.4 WhatisthedifferencebetweenanIntegratedDevelopmentEnvironmentandaneditor?....20014.4.5 CanIuse \( and \) instead of $ for LATEX?....200Chapter 15 ■ Modularisation....20115.1 TUTORIAL....20115.2 HOWTO....20715.2.1 ImportcodefromPythonfiles....20715.2.2 Breakupcodeintomodularcomponents....20815.3 EXERCISES....21015.4 FURTHERINFORMATION....21215.4.1 Whymodularise?....21215.4.2 WhydoIgetanimporterror?....21315.4.3 HowdoImakemyfileimportablefromotherdirectories?....213Chapter 16 ■ Documentation....21416.1 TUTORIAL....21416.1.1 Writingatutorial....21416.1.2 Writingthehow-toguides....21616.1.3 Writingtheexplanationssection....218xiv ■ Contents16.1.4 Writingthereferencesection....22116.2 HOWTO....22216.2.1 Writedocumentation....22216.2.2 Writemarkdown....22316.3 EXERCISES....22516.4 FURTHERINFORMATION....22516.4.1 Whatisdocumentation?....22516.4.2 Whatisthepurposeofthefourseparatesectionsindocumentation?22616.4.3 WhatalternativesaretheretowritingdocumentationintheREADME.md file?....226Chapter 17 ■ Testing....22717.1 TUTORIAL....22717.1.1 Writingtestsforcode....22717.1.2 Testingdocumentation....23117.1.3 Documentingthetests....23617.2 HOWTO....23717.2.1 Writean assert statement....23717.2.2 Write assert statementsforcodethatactsrandomly....23817.2.3 Writeatestfile....23917.2.4 Formatdoctests....24117.2.5 Rundoctests....24217.3 EXERCISES....24217.4 FURTHERINFORMATION....24217.4.1 Whyaretestswrittenasfunctions?....24217.4.2 Isthereamoreefficientwaytoruntests?....24217.4.3 Whatshouldbetested?....24317.4.4 Whydoyouneeddoctests?....24317.4.5 Whatistestdrivendevelopment?....24317.4.6 Howaremodularisation,documentationandtestingrelated?244Section IV AboutThisBookChapter 18 ■ HowThisBookIsWritten....247Bibliography....249Index....251
Описание
В этом материале разберём тему: tools.
Most programming texts introduce readers to the building blocks of programming and build up to using more sophisticated tools for a specific purpose, like doing particular mathematical tasks. Python for Mathematics introduces readers to effective methods for doing mathematics using the Python programming language. This is akin to teaching someone how to forge metal so as to make a nail, and then slowly working up to using sophisticated power tools so as to actually build something. In this way, the practical application of the tools can aid in the understanding of the theory. This book does things in a different way, by first getting readers to begin using and understanding the tools that are going to be helpful to them as mathematicians, and only then moving onto the granular details.
FeaturesComplete with engaging, practical exercisesMany useful and detailed coding examplesSuitable for undergraduates in mathematics, and other quantitative sciencesEmpowers readers to design and create their own Python tools.
Файл доступен для загрузки ниже.
Поделиться
Частые вопросы
Можно ли скачать «Python for Mathematics. The Python Series» бесплатно?
Да, «Python for Mathematics. The Python Series» доступна для бесплатного скачивания на нашем сайте в формате PDF. Ссылка на файл находится на этой странице.
В каком формате и какого размера файл?
Книга предоставляется в формате PDF, размер файла 4,0 МБ.
Кто автор и когда вышла книга?
автор — Knight Vincent, издательство CRC Press is an imprint of Taylor & Francis Group, LLC, год выпуска 2025, 268 страниц.
О чём книга «Python for Mathematics. The Python Series»?
Python for Mathematics introduces readers to effective methods for doing mathematics using the Python programming language.