Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Seite - 25 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 25 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 25 -

Bild der Seite - 25 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 25 -

1.5 MoreBasicConcepts 25 limit(sin(x)/x, x, 0) solve(5*x - 15, x) WolframAlpha isveryflexiblewith respect to syntax. Another impressive tool for symbolic computations is Sage6, which is a very comprehensivepackagewith theaimof“creatingaviable freeopensourcealterna- tive toMagma,Maple,MathematicaandMatlab”. Sage is implemented inPython. Projectswithextensivesymboliccomputationswillcertainlybenefitfromexploring Sage. 1.5.11 ConcludingRemarks Programmingdemandsyoutobeaccurate! In thischapter,youhaveseensomeexamplesofhowsimple thingsmaybedone in Python. Hopefully, you have tried to do the examples on your own. If you have, most certainly you have discovered that what youwrite in the code has to be very accurate. For example, with our previous example of four heights collected inanarrayh,writingh(0) insteadofh[0]givesanerror, even if you and I know perfectly well what youmean! Remember that it is not a human that runs your code, it is a machine. Therefore, even if the meaning of your code looksfine toahumaneye, it still has tocomply indetail to the rulesof the programming language. If not, yougetwarnings anderrormessages. This also goesfor loweranduppercase letters. Ifyoudofrom math import *andgive thecommandpi, youget3:1415:::. However, if youwritePi, yougetanerror message. Payattention tosuchdetailsalsowhentheyaregiven in laterchapters. Remembertoinsertcommentstoexplainyourcode Whenyouwriteacomputerprogram,youhave twoverydifferentkindsof read- ers. One is Python,whichwill interpret and runyour programaccording to the rules. Theother issomehuman,forexample,yourselforapeer. It isveryimpor- tant toorganizeandcomment thecodeso thatyoucangobacktoyourowncode after, e.g., ayearandstill understandwhat cleverconstructionsyouput in there. This is relevantwhen you need to change or extend your code (which usually happensoften in reality). Organizedcodingandgoodcommenting is evenmore critical if otherpeopleare supposed tounderstandcode thatyouhavewritten. Fastcodeversusreadableandcorrectcode Numericalcomputinghasastrong tradition inpayingmuchattention tocreating fast code. Real industrial applications of numerical computing often involves simulations that run forhours,days, andevenweeks. Fast code is tremendously important in those cases. The problemwith a strong focus on fast code, un- fortunately, is sometimes that clear and easily understandable constructions are replacedbycleverandless readable,but fastercode.However, forbeginnersit is most important to learn towrite readable andcorrect code.Wewillmake some 6http://sagemath.org/
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2016
Sprache
englisch
Lizenz
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
248
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python