Page - 2 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Image of the Page - 2 -
Text of the Page - 2 -
2 1 TheFirstFewSteps
maywant to analyze these data inExcel andmake somegraphics out of it. How-
ever,assumethereisnomenuinExcel thatallowsyouto importdata in thisspecific
format. Excelcanworkwithmanydifferentdataformats,butnot thisone.Youstart
searching for alternatives toExcel that can do the same and read this type of data
files. Maybe you cannot find any ready-made program directly applicable. You
have reached the pointwhereknowinghow towrite programsonyourownwould
beof great help to you! With someprogramming skills, youmaywrite your own
little programwhichcan translate onedata format to another.With that little piece
of tailoredcode,yourdatamaybe readandanalyzed,perhaps inExcel, orperhaps
byanewprogramtailored to thecomputations that themeasurementdatademand.
The real power of computers can only be utilized if you can program them.
By programmingyou can get the computer to do (most often!) exactlywhat you
want. Programming consists ofwriting a set of instructions in a very specialized
language that has adoptedwords and expressions fromEnglish. Such languages
areknownasprogrammingorcomputer languages. Thesetof instructions isgiven
to a programwhich can translate themeaning of the instructions into real actions
inside thecomputer.
Thepurposeof this book is to teach you towrite such instructions dedicated to
solvemathematicalandengineeringproblemsbyfundamentalnumericalmethods.
There are numerous computer languages for different purposes. Within the en-
gineering area, themost widely used computer languages are Python,MATLAB,
Octave, Fortran, C, C++, and to some extentMaple, andMathematica. Howyou
write the instructions (i.e. the syntax) differsbetween the languages. Let ususe an
analogy.
Assume youare an international kind of person, having friends abroad inEng-
land, Russia andChina. Theywant to try your favorite cake. What can you do?
Well, youmaywrite down the recipe in those three languagesand send themover.
Now, if you have been able to think correctlywhenwriting down the recipe, and
youhavewritten the explanationsaccording to the rules in each language, eachof
your friendswill produce the same cake. Your recipe is the “computer program”,
whileEnglish,Russian andChinese represent the “computer languages”with their
own rules of how towrite things. The endproduct, though, is still the same cake.
Note thatyoumayunintentionally introduceerrors inyour“recipe”.Dependingon
theerror, thismaycause“bakingexecution” to stop,orperhapsproduce thewrong
cake. In your computer program, the errors you introduce are called bugs (yes,
small insects! .. . for historical reasons), and the process of fixing them is called
debugging. When you try to run your program that contains errors, you usually
getwarningsor errormessages. However, the responseyougetdependson the er-
ror and theprogramming language. Youmayevenget no response, but simply the
wrong“cake”. Note that the rulesof aprogramming languagehave tobe followed
verystrictly. ThisdiffersfromlanguageslikeEnglishetc.,wherethemeaningmight
beunderstoodevenwith spellingerrorsand“slang” included.
Thisbookcomes in twoversions,one that isbasedonPython,andonebasedon
Matlab. Both Python andMatlab represent excellent programming environments
forscientificandengineeringtasks. Theversionyouare readingnow, is thePython
version.
Some of Python’s strong properties deservemention here: Many global func-
tions can be placed in only onefile, functions are straightforwardly transferred as
back to the
book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python
- Title
- Programming for Computations – Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2016
- Language
- English
- License
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 248
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik