Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Scientific Computing IDC205 Sunday 9 August 2009 1 • Scientific computing is concerned with constructing mathematical models and numerical solution techniques and using computers to analyse and solve scientific, social scientific and engineering problems. Sunday 9 August 2009 2 Grading scheme Weightage Sunday 9 August 2009 Internals (quiz, lab) 25% Midterm 30% Final 45% 3 • Linear Systems • Matrix Diagonalization • Calculating eigenvalues/eigenvectors • Random numbers/simulation Sunday 9 August 2009 4 History • Traditionally known as numerical analysis • Scientific computing as we know it started in the 1940s with the world war and cold war playing a major role in pushing its development • Codes for atomic bomb development • Codes for projectile targeting • Breaking ciphers Sunday 9 August 2009 5 Why Python? • Python is simple to use • extensive built-in run-time checks help to detect bugs • being a very-high-level language, it has high-level data types built in, such as flexible arrays and dictionaries that would cost days to implement efficiently in C or Fortran • Because of its general data types Python is applicable to a large problem domain Machine Language Assembly Sunday 9 August 2009 C Fortran Perl Python Lisp/Mathematica MATLAB x ∫e y 6 Why Python? • Python is simple to use • extensive built-in run-time checks help to detect bugs • being a very-high-level language, it has high-level data types built in, such as flexible arrays and dictionaries that would cost days to implement efficiently in C or Fortran • Because of its general data types Python is applicable to a large problem domain Machine Language Assembly Sunday 9 August 2009 C Fortran Perl Python Lisp/Mathematica MATLAB x ∫e y 6 Python vs MATLAB • the Python programming language is more powerful • the Python environment is completely open and made for integration with external tools, • a complete toolbox/module with lots of functions and classes can be contained in a single file (in contrast to a bunch of M-files), • transferring functions as arguments to functions is simpler, • nested, heterogeneous data structures are simple to construct and use, Sunday 9 August 2009 7 Python vs MATLAB (cont.) • object-oriented programming is more convenient, • interfacing C, C++, and Fortran code is better supported and therefore simpler, • scalar functions work with array arguments to a larger extent (without modifications of arithmetic operators), • the source is free and runs on more platforms. Sunday 9 August 2009 8 LINUX • "Linux is user friendly, it's just picky about its friends" One OS to rule them all, One OS to find them. One OS to call them all, And in salvation bind them. In the bright land of Linux, Where the hackers play. (J. Scott Thayer, with apologies to J.R.R.T.) The only "intuitive" interface is the nipple. After that, it's all learned. --Bruce Ediger Sunday 9 August 2009 9 Python resources • Beginners guide to Python • http://wiki.python.org/moin/BeginnersGuide • Python documentation • http://www.python.org/doc/ • Python official website • http://www.python.org/ Sunday 9 August 2009 10 LINUX resources • Basic LINUX commands • http://www.linuxconfig.org/linuxcommands Sunday 9 August 2009 11 Hello World! [farhat@webserver ~]$ python Python 2.4.3 (#1, Dec 11 2006, 11:39:03) [GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "Hello world!" Hello world! >>> Sunday 9 August 2009 12 Hello World! [farhat@webserver ~]$ python Python 2.4.3 (#1, Dec 11 2006, 11:39:03) [GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "Hello world!" Hello world! >>> Sunday 9 August 2009 12 Hello World! [farhat@webserver ~]$ python Python 2.4.3 (#1, Dec 11 2006, 11:39:03) [GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "Hello world!" Hello world! >>> [farhat@webserver ~]$ cat > helloworld.py #!/usr/bin/python print "Hello World!" [farhat@webserver ~]$ python helloworld.py Hello World! [farhat@webserver ~]$ chmod 755 helloworld.py [farhat@webserver ~]$ ./helloworld.py Hello World! [farhat@webserver ~]$ Sunday 9 August 2009 12 If [farhat@webserver ~]$ cat if.py #!/usr/bin/python print "Is the world flat?" if True: print "Be careful at the edge!" [farhat@webserver ~]$ python if.py Is the world flat? Be careful at the edge! [farhat@webserver ~]$ Sunday 9 August 2009 13 For loop >>> a = ['Mary', 'had', 'a', 'little', 'lamb'] >>> for i in range(len(a)): ... print i, a[i] ... 0 Mary 1 had 2a 3 little 4 lamb Sunday 9 August 2009 14 • Write a python program to output Fibonnaci numbers upto 1000 Sunday 9 August 2009 15