Introduction to Computational Modeling

Size: px
Start display at page:

Download "Introduction to Computational Modeling"

Transcription

1 Introduction to Computational Modeling Lecture 1 : Introduction to UNIX and Fortran Instructor : Cedric Weber Course : 4CCP1000

2 General informations Ø Lecture: Thursday, 9-10am Ø Practice: K3.16 (25C), 10am- 13pm Ø Schedule Ø First term: 10 Lectures, 10 practice sessions Ø 1h Lecture / 3h practice Ø Lecture : short overview of the theory and context Ø Practice : programming hands- on Ø Office : 4.02D Ø Office hours : Monday pm / Tuesday am Ø Website : keats.kcl.ac.uk Ø cedric.weber@kcl.ac.uk Ø Examination 1 Ø 1) A set of problems to be solved in the computer room (3h), codes and answers collected at the end of the examination and marked Ø Last week of December Ø 2) A 10 page report where a set of problems is solved and presented Ø After the Christmas break Ø Contributes 25% to the final grade of the Laboratory module Ø Computers Ø Your KCL login Ø To reset it : kclpword.kcl.ac.uk 2

3 Schedule Class/Week Chapter Topic Milestones 1 Monte Carlo UNIX system / Fortran 2 Monte Carlo Fibonacci sequence 3 Monte Carlo Random variables 4 Monte Carlo Central Limit Theorem 5 Monte Carlo Monte Carlo integration Milestone 1 6 Differential equations The Pendulum 7 Differential equations A Quantum Particle in a box 8 Differential equations The Tacoma bridge Milestone 2 9 Linear Algebra System of equations 10 Linear Algebra Matrix operations Milestone 3 3

4 Buckle up Lecture: Theory historical context : ~20 min Programming : ~30 min The lecture is merely an overview of the topic covered by the practice session 100% 90% 80% You will be confused until ~Week 5 and really wonder what we are doing, that s to be expected with programming In the practice session you can ask the TA any questions or help to get through the problems 70% 60% 50% 40% Learning curve I expect from you to : Solve problems during practice sessions Go through the lecture notes before the lecture starts Spend ~1h on the lecture notes after the lecture, write your questions down and contact me or the TA to go through those points 30% 20% 10% 0% In each lecture we will add one or a few programming features, and see how they can be used to solve important problems in Physics and Maths week 1 week 2 week 3 week 4 week 5 week 6 week 7 week 8 week 9 week 10 4

5 Reading list / Literature For the Theory For the Programming Numerical Analysis, 2 nd ed., Timothy Sauer Modern Fortran explained, Metcalf, Reid, Cohen, Oxford Available at the KCL library 5

6 Part 1 : UNIX/Linux Operative system 6

7 What is Unix/Linux? 7 Ø Multi- tasking, multi- user architecture Ø Stability, portability and powerful networking capabilities Ø Available for laptops, servers, Ø Lightweight : does not require state of the art Ø Open- source (=free) : Ø Open office Ø firefox explorer Ø Mozzila Ø = microsoft office = internet = outlook Ø Remote access (work from home, supercomputers )

8 Linux File system Ø Files are contained in directories Ø Directories follow a tree structure Ø The source directory is denoted / Ø The path to a given directory is denoted by its location in the tree : / book / chapter / page / Ø Means the directory page is contained in the directory chapter, itself contained in the directory book Ø Your personal file are contained in Ø /home/ your_login / Ø An equivalent shorthand notation is : ~/ /etc/ /opt/ /usr/ /home/your_login/ [ = ~/ ] /home/. /tmp/ /scratch/ Ø You can access your files from any computers in the computer room(shared file system) 8

9 Getting started with Linux Ø You will be first prompted to enter your login Ø Once your credentials entered, you will access a desktop session, with various menus Ø Find and open the program terminal in utilities 9 Ø You can open/close programs and execute commands from the terminal Ø Example : Ø to display the files in this directory, type ls, and press enter Ø A list of your files and directories will be shown Ø To enter the directory tmp : Ø Type cd tmp, press enter

10 File system navigation To navigate through directories cd [space] name_of_directory cd change your location in the file tree from the current directory to the new directory name_of_directory bring you back to your home directory (~/). This is equivalent to : cd ~/ cd [space].. goes one directory up in the tree ls list the content of name_of_directory pwd gives back the position in the file tree Important : if you hit the tab key and entered the first half of a command or directory name, the second half will be auto- completed 10

11 Directory operation File/directory operations mkdir [space] name_of_directory creates a directory with name name_of_directory rm [space] - r [space] name_of_directory deletes this directory and all its content cp [space] r [space] name_of_directory [space] name_of_target Copies the directory and content File operation cp [space] file [space] file_copy copies the files named file to a file named file_copy rm [space] file_to_erase erases the file named file_to_erase 11

12 Account management To manage your UNIX account : quota will give you the amount of disk space that you can use. top displays the list of running processes, the left column is a job/ process identifier (PID number) kill - 9 PID stops a running calculation. PID is the job identifier obtained by top If you wish to stop or exit a running calculation, press CTRL and C at the same time, or CTRL and D 12

13 Nedit / Gedit : opens a text editor program in window mode. Type in the terminal : gedit& Gnuplot : opens a plotting tool in terminal mode. Once in this program, you can plot functions. Step 1, type: f(x)=x*x*3, hit enter Step 2, type: p f(x), enter. The function will be displayed. Plotting interval: To plot the function from x=- 3 to x=+3, Step 2, type: p [- 3:3][] f(x), hit enter. File content plotting: to plot the content of the file name_of_file, which has as its first column the x coordinates, and as a second column the y coordinates, Step 2, type: p [- 3:3][] name_of_file To produce an output file of the plot, type: Set term postscript Set output name_of_the_file.ps rep Text editor, simple plotting tool Once finished, type exit to return to the terminal To display the produced graphics, type in the terminal: gv name_of_the_file.ps Type in the terminal: gnuplot xmgrace: in the terminal, type: xmgrace name_of_file to display a two column file Type in the terminal: xmgrace& 13

14 Ø What does programming mean? Ø 1) Write a series of specific instructions (e.g. a scientific calculation) in a given language (programming) Ø 2) Transform these instructions into a program that the computer can execute (compilation) Ø 3) Execute this program (execution) Ø 4) Obtain results (numbers, plot) as a result of this scientific calculation (post- processing) STEP 1 : With a text editor, write a series of instruction (programming) Ø Fortran programming language Ø Modern programming language with Python and C Ø Syntax is convenient for scientific applications Ø Fast and efficient Ø open- source compiler : gfortran Ø Large number of available scientific libraries Ø Increasing number of functionalities and continuously updated/improved versions 14 STEP 2 : Transform the text into a program (compilation) STEP 3 : execute the program (execution)

15 Part 2 : Fortran Programming 15

16 What is a program? Ø A program is a list of instructions Ø Each line contains one instruction 1. Program something 2. instruction 1 3. instruction instruction 3 5. end program Ø Ø Ø Instructions are executed from the top to the bottom, one by one When executing your software, the computer executes all the lines until it reaches the end program instruction Vertical axis can be thought of as a timeline Ø The program starts at the first line, and ends at the last line Ø Each instruction has a very precise syntax, every coma, space, is important. 16

17 The Hello program 1. program hello 2. write(*,*) hi there! 3. end program 1. program hello 2.! This is just a notice 3. write(*,*) hi there! Ø Ø Ø Ø Ø program / end program define the scope of the series of instructions that constitute the program In between these two lines, you can add the instructions that you want to execute, the program stops at line 3 A name is given to the program scope, in this case hello. Write(*,*) is a programming command : it displays on your screen the text given as an argument, so here the string of characters hi there. The text shown on the display by write(*,*) is given within quotes. This allows the computer to differentiate this string of characters from the rest of your program 4. end program Ø Line starting with an exclamation mark are not taken into account by the program. They can be used to add some notes or reminder for yourself. Those are called comments 17

18 Spot the mistake 1. program hello write(*,*) 2 4.! write(*,*) 1 5. write(*,*) 2 6. write(*,*) 3 Ø If I want to display 1,2,3, where is the mistake in the program? What do I need to change? 7. end program 18

19 Compilation 1) write your program with any text editor (the hello program) 2) save it to a file, the filename can be anything, but should end with the extension f90 : myprogram.f90 3) open a terminal, and type : gfortran [space] myprogram.f90 4) Gfortran is a command (compiler) that converts the text to an executable software/program, the program is now called a.out 5) to execute your program, type in the terminal :. / a.out 6) If you modify the text/series of instructions in myprogram.f90, you need to compile again, obtain a new program, and execute it again 19

20 Optional : Linking and executable name You can also change the name of the obtained program (instead of getting a.out) by specifying the additional option o to the compiler : In the terminal, type : gfortran [space ] o [space ] progname.out [space ] myprogram.f90 If any errors in your code (syntax, misspells, typos, conceptual problems), your will receive a list of errors. Correct your code and try to compile again This will produce the executable prog_name.out To run your program, write in the terminal:./progname.out 20

21 Variables We want to perform some calculations with the computer, and for this we need to store the result of an operation in the memory. A variable is a location in the memory where you can store the result of an addition, subtraction etcetera. We could denote this location with a number (or an address), but it is more convenient to just give it a name (variable). There are different types of variables in Fortran : integer : whole numbers, positive and negative real : rational numbers (floating point numbers) Single precision Double precision character : a string of character (text) hello I am here 21

22 Integer / real representation Both integer and real are stored in the computer s memory in the binary basis (in terms of 0 and 1) Integers are decomposed in powers of 2 : Sign bit 130 = = 2^7 + 2^1 " Question 1 : How can you write this in terms of 0 and 1?" Question 2 : How would I represent -130? " Question 3 : How many bytes if 32 bits? " 0" 0" 0" 1" 0" bit 0" 0" 0" 0" 1" 0" 2^31" 2^30" 2^29".." 2^7" 2^6" 2^5" 2^4" 2^3" 2^2" 2^1" 2^0" Byte / octet 22

23 The single precision real number is represented as follows:" A constant shift is commonly applied to exp, so it runs from -127 to +128" Largest number : =3.4 x smallest number : =5.8 x " Representation of Floating Number ( 1) s 2 exp mantissa Variable Definition Number of bits s" sign" 1" exp" Exponent between 0-255" 8" mantissa" Coded as : m 1 (2-1 ) + m 2 (2-2 ) + + m 23 ( 2-23 )" 23" Only the 7-8 digits after the coma are significant in single precision" Example, is obtained with : " s=0; sign=-1 0 " "exp=0; exp=2 0 "m 1 =1; mantissa=2-1" 23

24 Using variables Left side : variable type Right side : variable names (your choice) Block of Variable declarations 1. program testingvariables" 2. Real(8) ":: " var1" 3. Integer(4) ":: " var2,var3" Integer à integer(4) Execution Block of the program 4. var1 = 1.10" 5. write(*,*) "var1 " 6. var2 = 2 " 7. write(*,*) "var2" 8. end program" 24 Floating Single precision à real(4) Floating Double precision à real(8) You can t declare a variable in the execution block & all variables need to be declared

25 Spot the 3 mistakes Block of Variable declarations Execution Block of the program 1. program testingvariables" 2. Integer(4) " ":: " var2" " " 3. write(*,*) "var2" 4. var2 = 2 " 5. real(8) " " ":: " var4" 6. var4 = 1.10" 7. write(*,*) "var4 " 8. var2 = 2 " 9. write(*,*) "var3" 10. end program" 25

26 Variable Assignment 1. var1 = 1" 2. var1 = 2*var1 + 1" 3. write(*,*) var1 " Even more confusing!! Remember : 1. Line (2) is not an equation 2. Line are executed one by one from the top down to the bottom. 3. At Line (2), the computer first evaluates all the operation contained on the right hand side, and obtains a numerical result 4. This numerical result is stored in the variable appearing on the left hand side, which is assigned a new value = [Fill in] 26

27 Basic operations var1 = " Extremely confusing!! This operation is not an equation It is a multi- step process : 1. The computer always first carries out all the operation contained on the right hand side, and obtains a numerical result 2. This numerical result is stored in the variable appearing on the left hand side, which is assigned a new value Basic operations : addition: substraction: division: multiplication: to the power n: to the power 1/n: a+b a- b a/b a*b a**n a**(1.0/2.0) Priorities: Elements in brackets are done first Powers are done before multiplications Multiplications are done before additions If any doubt, use a bracket 27

28 Example Block of Variable declarations Execution Block of the program 1. program testingvariables" 2. Integer(4) " ":: " var1" " 3. var1 = 1" 4. write(*,*) var1 " 5. var1= var1 + 2 " 6. write(*,*) var1 " 7. Var1= var1 * 2 " 8. Write(*,*) var1" 9. end program" Questions : 1) How many outputs displayed? [Fill in] 2) Write them here : [Fill in] 28

29 Operations with different types Type are conserved during operations, so if i and j are integers, i/j is also an integer (floored down) i = 2/3 will give i=0 i = 4/3 will give i=1 Integers involved in floating operations are automatically converted Example : a = 10.0 / 3, 3 is converted internally to 3.0 Warning: some ambiguous cases exists, and will give different results on different compilers, such as : 10.0 * 2 / 3 Why is it ambiguous? To avoid any confusion, integer can be transformed to real numbers with the function dble 10.0 * dble(2)/dble(3) is equivalent to 10.0 * 2.0/ a = 2.0 * b / dble(i), where a,b, are real numbers and i is an integer

30 Operations mixing different types Integer(4) ":: var2" Real(8) ":: var1" var1 = var2 / 2 " If var1 is a floating number and var2 an integer, and they appear in the same operation, we need to convert var2 to a floating number Integer to floating type conversion : Simply insert dble( ) around var2, this will transform var2 from an integer to a floating number var1 = dble(var2) / 2 " Warnings : Integer divisions are floored down Example : var2 = 1 / 2 will give the value zero to the variable var2 To distinguish integer values from floating values, we always append explicitly a coma to floating point numbers Example : var1 = 1.0 / 2.0 [and not var1 = 1 ] 30

31 Available functions for double precision floating numbers 1. program testop 2. real(8) :: a, b 3. a=sin(2.0) 4. b=cos( a ) 5. write(*,*) b=, b 6. end program Functions readily available in Fortran:" Trigonometric functions:" " "à sin(x), cos(x), tan(x)" Inverse functions:" " "à asin(x),acos(x),atan(x)" Hyperbolic functions: " " "à sinh(x),cosh(x),tanh(x)" units of x are radians above" Absolute value:" " "à abs(x)" Exponentials:" " "à exp(x)" Square root:" " "à Sqrt(x)" 31

32 Practice in K3.16 / 25 C 1 st Floor - Kings Building 32

Computational modeling

Computational modeling Computational modeling Lecture 3 : Random variables Theory: 1 Random variables Programming: 1 Implicit none statement 2 Modules 3 Outputs 4 Functions 5 Conditional statement Instructor : Cedric Weber Course

More information

Computational modeling

Computational modeling Computational modeling Lecture 5 : Monte Carlo Integration Physics: Integration The Monte Carlo method Programming: Subroutine Differences Subroutine/Function The Fortran random number subroutine Monte

More information

Introduction to Engineering gii

Introduction to Engineering gii 25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.

More information

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types Introduction to Computer Programming in Python Dr William C Bulko Data Types 2017 What is a data type? A data type is the kind of value represented by a constant or stored by a variable So far, you have

More information

VARIABLES Storing numbers:

VARIABLES Storing numbers: VARIABLES Storing numbers: You may create and use variables in Matlab to store data. There are a few rules on naming variables though: (1) Variables must begin with a letter and can be followed with any

More information

Part I. Introduction to Linux

Part I. Introduction to Linux Part I Introduction to Linux 7 Chapter 1 Linux operating system Goal-of-the-Day Familiarisation with basic Linux commands and creation of data plots. 1.1 What is Linux? All astronomical data processing

More information

An Introduction to Unix

An Introduction to Unix An Introduction to Unix Sylvia Plöckinger March 3, 2011 Sylvia Plöckinger () An Introduction to Unix March 3, 2011 1 / 29 General Information Find this file on: http://homepage.univie.ac.at/nigel.mitchell/numprac/

More information

AMS 27L LAB #1 Winter 2009

AMS 27L LAB #1 Winter 2009 AMS 27L LAB #1 Winter 2009 Introduction to MATLAB Objectives: 1. To introduce the use of the MATLAB software package 2. To learn elementary mathematics in MATLAB Getting Started: Log onto your machine

More information

9 Using Equation Networks

9 Using Equation Networks 9 Using Equation Networks In this chapter Introduction to Equation Networks 244 Equation format 247 Using register address lists 254 Setting up an enable contact 255 Equations displayed within the Network

More information

Scientific Computing: Lecture 1

Scientific Computing: Lecture 1 Scientific Computing: Lecture 1 Introduction to course, syllabus, software Getting started Enthought Canopy, TextWrangler editor, python environment, ipython, unix shell Data structures in Python Integers,

More information

AMS 200: Working on Linux/Unix Machines

AMS 200: Working on Linux/Unix Machines AMS 200, Oct 20, 2014 AMS 200: Working on Linux/Unix Machines Profs. Nic Brummell (brummell@soe.ucsc.edu) & Dongwook Lee (dlee79@ucsc.edu) Department of Applied Mathematics and Statistics University of

More information

Math 2250 MATLAB TUTORIAL Fall 2005

Math 2250 MATLAB TUTORIAL Fall 2005 Math 2250 MATLAB TUTORIAL Fall 2005 Math Computer Lab The Mathematics Computer Lab is located in the T. Benny Rushing Mathematics Center (located underneath the plaza connecting JWB and LCB) room 155C.

More information

ANSI C Programming Simple Programs

ANSI C Programming Simple Programs ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double

More information

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.

More information

LAB 1 General MATLAB Information 1

LAB 1 General MATLAB Information 1 LAB 1 General MATLAB Information 1 General: To enter a matrix: > type the entries between square brackets, [...] > enter it by rows with elements separated by a space or comma > rows are terminated by

More information

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB:

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB: Contents VARIABLES... 1 Storing Numerical Data... 2 Limits on Numerical Data... 6 Storing Character Strings... 8 Logical Variables... 9 MATLAB S BUILT-IN VARIABLES AND FUNCTIONS... 9 GETTING HELP IN MATLAB...

More information

PY502, Computational Physics Instructor: Prof. Anders Sandvik

PY502, Computational Physics Instructor: Prof. Anders Sandvik PY502, Computational Physics Instructor: Prof. Anders Sandvik Office: SCI 450A, phone: 353-3843, e-mail: sandvik@bu.edu Lectures: Tuesday/Thursday 11-12:15 in PRB 146 Tutorials/discussions, some Fridays

More information

2. Basic Elements of Fortran

2. Basic Elements of Fortran 2. Basic Elements of Fortran Structure of a Fortran Program 31 characters must be in the 1st line if present declaration section program my_first_program! Declare variables integer :: i, j, k! i, j, k

More information

Tutorial 1: Unix Basics

Tutorial 1: Unix Basics Tutorial 1: Unix Basics To log in to your ece account, enter your ece username and password in the space provided in the login screen. Note that when you type your password, nothing will show up in the

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how

More information

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017 Einführung in die Programmierung für Physiker WS 207/208 Marc Wagner Francesca Cuteri: cuteri@th.physik.uni-frankfurt.de Alessandro Sciarra: sciarra@th.physik.uni-frankfurt.de Exercise sheet To be corrected

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Understand integer arithmetic Understand mixed-mode arithmetic Understand the hierarchy of arithmetic operations Introduce the use of intrinsic functions Real Arithmetic Valid expressions

More information

last time in cs recitations. computer commands. today s topics.

last time in cs recitations. computer commands. today s topics. last time in cs1007... recitations. course objectives policies academic integrity resources WEB PAGE: http://www.columbia.edu/ cs1007 NOTE CHANGES IN ASSESSMENT 5 EXTRA CREDIT POINTS ADDED sign up for

More information

Getting started with Hugs on Linux

Getting started with Hugs on Linux Getting started with Hugs on Linux COM1022 Functional Programming Techniques Dr Hans Georg Schaathun University of Surrey Autumn 2009 Week 7 Dr Hans Georg Schaathun Getting started with Hugs on Linux Autumn

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

CSC116: Introduction to Computing - Java

CSC116: Introduction to Computing - Java CSC116: Introduction to Computing - Java Intro to CSC116 Course Information Introductions Website Syllabus Computers First Java Program Text Editor Helpful Commands Java Download Course Instructor: Instructors

More information

Programming Studio #1 ECE 190

Programming Studio #1 ECE 190 Programming Studio #1 ECE 190 Programming Studio #1 Announcements In Studio Assignment Introduction to Linux Command-Line Operations Recitation Floating Point Representation Binary & Hexadecimal 2 s Complement

More information

CSC116: Introduction to Computing - Java

CSC116: Introduction to Computing - Java CSC116: Introduction to Computing - Java Course Information Introductions Website Syllabus Computers First Java Program Text Editor Helpful Commands Java Download Intro to CSC116 Instructors Course Instructor:

More information

CSC116: Introduction to Computing - Java

CSC116: Introduction to Computing - Java CSC116: Introduction to Computing - Java Course Information Introductions Website Syllabus Schedule Computing Environment AFS (Andrew File System) Linux/Unix Commands Helpful Tricks Computers First Java

More information

Computational Modelling 102 (Scientific Programming) Tutorials

Computational Modelling 102 (Scientific Programming) Tutorials COMO 102 : Scientific Programming, Tutorials 2003 1 Computational Modelling 102 (Scientific Programming) Tutorials Dr J. D. Enlow Last modified August 18, 2003. Contents Tutorial 1 : Introduction 3 Tutorial

More information

Welcome. Please Sign-In

Welcome. Please Sign-In Welcome Please Sign-In Day 1 Session 1 Self-Evaluation Topics to be covered: Equations Systems of Equations Solving Inequalities Absolute Value Equations Equations Equations An equation says two things

More information

Our Strategy for Learning Fortran 90

Our Strategy for Learning Fortran 90 Our Strategy for Learning Fortran 90 We want to consider some computational problems which build in complexity. evaluating an integral solving nonlinear equations vector/matrix operations fitting data

More information

CSC 101 Spring 2010 Lab #8 Report Gradesheet

CSC 101 Spring 2010 Lab #8 Report Gradesheet CSC 101 Spring 2010 Lab #8 Report Gradesheet Name WFU Username Lab Section: A B C D Partner s Name (if you had one): Topic Points Notes Pre-lab questions 20 total - 5 at 4 points each Lab report questions

More information

Lecture 1. Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering?

Lecture 1. Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering? Lecture 1 Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering? Welcome to ENGR 102 Syllabus review Your Time Expectations (in

More information

Introduction to Linux

Introduction to Linux Introduction to Linux The command-line interface A command-line interface (CLI) is a type of interface, that is, a way to interact with a computer. Window systems, punched cards or a bunch of dials, buttons

More information

1 Getting Started with Linux.

1 Getting Started with Linux. PHYS-4007/5007: omputational Physics Tutorial #1 Using Linux for the First Time 1 Getting Started with Linux. The information of logging in on the Linux side of the computers in Brown Hall 264 can be found

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. The doc is

More information

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

More information

General MATLAB Information 1

General MATLAB Information 1 Introduction to MATLAB General MATLAB Information 1 Once you initiate the MATLAB software, you will see the MATLAB logo appear and then the MATLAB prompt >>. The prompt >> indicates that MATLAB is awaiting

More information

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman 1. BASICS OF PYTHON JHU Physics & Astronomy Python Workshop 2017 Lecturer: Mubdi Rahman HOW IS THIS WORKSHOP GOING TO WORK? We will be going over all the basics you need to get started and get productive

More information

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt ULI101 Week 03 Week Overview Absolute and relative pathnames File name expansion Shell basics Command execution in detail Recalling and editing previous commands Quoting Pathnames A pathname is a list

More information

An Introduction to MATLAB See Chapter 1 of Gilat

An Introduction to MATLAB See Chapter 1 of Gilat 1 An Introduction to MATLAB See Chapter 1 of Gilat Kipp Martin University of Chicago Booth School of Business January 25, 2012 Outline The MATLAB IDE MATLAB is an acronym for Matrix Laboratory. It was

More information

ME 261: Numerical Analysis. ME 261: Numerical Analysis

ME 261: Numerical Analysis. ME 261: Numerical Analysis ME 261: Numerical Analysis 3. credit hours Prereq.: ME 163/ME 171 Course content Approximations and error types Roots of polynomials and transcendental equations Determinants and matrices Solution of linear

More information

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE

More information

AMS 27L LAB #2 Winter 2009

AMS 27L LAB #2 Winter 2009 AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles

More information

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C Welcome! Welcome to your CpSc 111 lab! For each lab this semester, you will be provided a document like this to guide you. This material, as

More information

CITS2401 Computer Analysis & Visualisation

CITS2401 Computer Analysis & Visualisation FACULTY OF ENGINEERING, COMPUTING AND MATHEMATICS CITS2401 Computer Analysis & Visualisation SCHOOL OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Topic 3 Introduction to Matlab Material from MATLAB for

More information

Python Programming Exercises 1

Python Programming Exercises 1 Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them

More information

Physics 2660: Fundamentals of Scientific Computing. Lecture 7 Instructor: Prof. Chris Neu

Physics 2660: Fundamentals of Scientific Computing. Lecture 7 Instructor: Prof. Chris Neu Physics 2660: Fundamentals of Scientific Computing Lecture 7 Instructor: Prof. Chris Neu (chris.neu@virginia.edu) Reminder HW06 due Thursday 15 March electronically by noon HW grades are starting to appear!

More information

Variables and Typing

Variables and Typing Variables and Typing Christopher M. Harden Contents 1 The basic workflow 2 2 Variables 3 2.1 Declaring a variable........................ 3 2.2 Assigning to a variable...................... 4 2.3 Other

More information

Graphics calculator instructions

Graphics calculator instructions Graphics calculator instructions Contents: A Basic calculations B Basic functions C Secondary function and alpha keys D Memory E Lists F Statistical graphs G Working with functions H Two variable analysis

More information

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 Ziad Matni Dept. of Computer Science, UCSB Administrative CHANGED T.A. OFFICE/OPEN LAB HOURS! Thursday, 10 AM 12 PM

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Understand how to set aliases Understand globbing and wildcards in the shell Matching multiple filenames with patterns Understand shell variables Setting up your bash shell Invoking

More information

Starting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below.

Starting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below. What is MATLAB? MATLAB (short for MATrix LABoratory) is a language for technical computing, developed by The Mathworks, Inc. (A matrix is a rectangular array or table of usually numerical values.) MATLAB

More information

LECTURE 0: Introduction and Background

LECTURE 0: Introduction and Background 1 LECTURE 0: Introduction and Background September 10, 2012 1 Computational science The role of computational science has become increasingly significant during the last few decades. It has become the

More information

Intermediate Programming, Spring Misha Kazhdan

Intermediate Programming, Spring Misha Kazhdan 600.120 Intermediate Programming, Spring 2017 Misha Kazhdan Outline Unix/Linux command line Basics of the Emacs editor Compiling and running a simple C program Cloning a repository Connecting to ugrad

More information

Interactive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple

Interactive MATLAB use. Often, many steps are needed. Automated data processing is common in Earth science! only good if problem is simple Chapter 2 Interactive MATLAB use only good if problem is simple Often, many steps are needed We also want to be able to automate repeated tasks Automated data processing is common in Earth science! Automated

More information

COSC UNIX. Textbook. Grading Scheme

COSC UNIX. Textbook. Grading Scheme COSC 2306 - UNIX Education has failed in a very serious way to convey the most important lesson science can teach: skepticism. - David Suzuki Fall 2008 Aaron Langille Textbook Linux for Programmers and

More information

Getting Started With UNIX Lab Exercises

Getting Started With UNIX Lab Exercises Getting Started With UNIX Lab Exercises This is the lab exercise handout for the Getting Started with UNIX tutorial. The exercises provide hands-on experience with the topics discussed in the tutorial.

More information

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview Computer Science 322 Operating Systems Mount Holyoke College Spring 2010 Topic Notes: C and Unix Overview This course is about operating systems, but since most of our upcoming programming is in C on a

More information

Programming in Mathematics. Mili I. Shah

Programming in Mathematics. Mili I. Shah Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window

More information

Introduction to Python, Cplex and Gurobi

Introduction to Python, Cplex and Gurobi Introduction to Python, Cplex and Gurobi Introduction Python is a widely used, high level programming language designed by Guido van Rossum and released on 1991. Two stable releases: Python 2.7 Python

More information

Computational Programming with Python

Computational Programming with Python Numerical Analysis, Lund University, 2017 1 Computational Programming with Python Lecture 1: First steps - A bit of everything. Numerical Analysis, Lund University Lecturer: Claus Führer, Alexandros Sopasakis

More information

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80 CSE 303 Lecture 2 Introduction to bash shell read Linux Pocket Guide pp. 37-46, 58-59, 60, 65-70, 71-72, 77-80 slides created by Marty Stepp http://www.cs.washington.edu/303/ 1 Unix file system structure

More information

Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.

Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5. Week 2: Console I/O and Operators Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.1) CS 1428 Fall 2014 Jill Seaman 1 2.14 Arithmetic Operators An operator is a symbol that tells the computer to perform specific

More information

WHAT IS MATLAB?... 1 STARTING MATLAB & USING THE COMMAND LINE... 1 BASIC ARITHMETIC OPERATIONS... 5 ORDER OF OPERATIONS... 7

WHAT IS MATLAB?... 1 STARTING MATLAB & USING THE COMMAND LINE... 1 BASIC ARITHMETIC OPERATIONS... 5 ORDER OF OPERATIONS... 7 Contents WHAT IS MATLAB?... 1 STARTING MATLAB & USING THE COMMAND LINE... 1 BASIC ARITHMETIC OPERATIONS... 5 ORDER OF OPERATIONS... 7 WHAT IS MATLAB? MATLAB stands for MATrix LABoratory. It is designed

More information

Welcome to EGR 106 Foundations of Engineering II

Welcome to EGR 106 Foundations of Engineering II Welcome to EGR 106 Foundations of Engineering II Course information Today s specific topics: Computation and algorithms MATLAB Basics Demonstrations Material in textbook chapter 1 Computation What is computation?

More information

(Refer Slide Time: 02:59)

(Refer Slide Time: 02:59) Numerical Methods and Programming P. B. Sunil Kumar Department of Physics Indian Institute of Technology, Madras Lecture - 7 Error propagation and stability Last class we discussed about the representation

More information

Python lab session 1

Python lab session 1 Python lab session 1 Dr Ben Dudson, Department of Physics, University of York 28th January 2011 Python labs Before we can start using Python, first make sure: ˆ You can log into a computer using your username

More information

CS 101: Computer Programming and Utilization. Abhiram Ranade

CS 101: Computer Programming and Utilization. Abhiram Ranade CS 101: Computer Programming and Utilization Abhiram Ranade CS 101: Computer Programming and Utilization Abhiram Ranade Course Overview How to represent problems on a computer and solve them Programming

More information

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.) 1 Introduction 1 CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.) This laboratory is intended to give you some brief experience using the editing/compiling/file

More information

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you. https://www.virtualbox.org/

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you. https://www.virtualbox.org/ Virtual Machine Anyone have problems installing it? VM: Virtual Box - allows you to run a different operating system within the current operating system of your machine. https://www.virtualbox.org/ Linux

More information

Command Line Interface The basics

Command Line Interface The basics Command Line Interface The basics Marco Berghoff, SCC, KIT Steinbuch Centre for Computing (SCC) Funding: www.bwhpc-c5.de Motivation In the Beginning was the Command Line by Neal Stephenson In contrast

More information

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An. CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some

More information

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment. CPS109 Lab 1 Source: Partly from Big Java lab1, by Cay Horstmann. Objective: i. To become familiar with the Ryerson Computer Science laboratory environment. ii. To obtain your login id and to set your

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 11: Floating Point & Floating Point Addition Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Last time: Single Precision Format

More information

Welcome (back) to CS1007!

Welcome (back) to CS1007! Welcome (back) to CS1007! Introduction to Computer Science in Java Spring 2002 Section 001: TR 2.40pm - 3.55pm 301 Pupin Section 002: TR 11.00am - 12.15pm 209 Havemeyer Professor Elizabeth Sklar email:

More information

CT 229 Java Syntax Continued

CT 229 Java Syntax Continued CT 229 Java Syntax Continued 06/10/2006 CT229 Lab Assignments Due Date for current lab assignment : Oct 8 th Before submission make sure that the name of each.java file matches the name given in the assignment

More information

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip.

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip. MAPLE Maple is a powerful and widely used mathematical software system designed by the Computer Science Department of the University of Waterloo. It can be used for a variety of tasks, such as solving

More information

ELEMENTARY MATLAB PROGRAMMING

ELEMENTARY MATLAB PROGRAMMING 1 ELEMENTARY MATLAB PROGRAMMING (Version R2013a used here so some differences may be encountered) COPYRIGHT Irving K. Robbins 1992, 1998, 2014, 2015 All rights reserved INTRODUCTION % It is assumed the

More information

COMP s1 Lecture 1

COMP s1 Lecture 1 COMP1511 18s1 Lecture 1 1 Numbers In, Numbers Out Andrew Bennett more printf variables scanf 2 Before we begin introduce yourself to the person sitting next to you why did

More information

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu 0. What is MATLAB? 1 MATLAB stands for matrix laboratory and is one of the most popular software for numerical computation. MATLAB s basic

More information

/23/2004 TA : Jiyoon Kim. Recitation Note 1

/23/2004 TA : Jiyoon Kim. Recitation Note 1 Recitation Note 1 This is intended to walk you through using STATA in an Athena environment. The computer room of political science dept. has STATA on PC machines. But, knowing how to use it on Athena

More information

Python for Astronomers. Week 1- Basic Python

Python for Astronomers. Week 1- Basic Python Python for Astronomers Week 1- Basic Python UNIX UNIX is the operating system of Linux (and in fact Mac). It comprises primarily of a certain type of file-system which you can interact with via the terminal

More information

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University Lesson #3 Variables, Operators, and Expressions Variables We already know the three main types of variables in C: int, char, and double. There is also the float type which is similar to double with only

More information

Introduction to MATLAB

Introduction to MATLAB Outlines September 9, 2004 Outlines Part I: Review of Previous Lecture Part II: Part III: Writing MATLAB Functions Review of Previous Lecture Outlines Part I: Review of Previous Lecture Part II: Part III:

More information

Computer Science 121. Scientific Computing Winter 2016 Chapter 3 Simple Types: Numbers, Text, Booleans

Computer Science 121. Scientific Computing Winter 2016 Chapter 3 Simple Types: Numbers, Text, Booleans Computer Science 121 Scientific Computing Winter 2016 Chapter 3 Simple Types: Numbers, Text, Booleans 3.1 The Organization of Computer Memory Computers store information as bits : sequences of zeros and

More information

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version... Contents Note: pay attention to where you are........................................... 1 Note: Plaintext version................................................... 1 Hello World of the Bash shell 2 Accessing

More information

Using the Zoo Workstations

Using the Zoo Workstations Using the Zoo Workstations Version 1.86: January 16, 2014 If you ve used Linux before, you can probably skip many of these instructions, but skim just in case. Please direct corrections and suggestions

More information

Getting started with Hugs on Linux

Getting started with Hugs on Linux Getting started with Hugs on Linux CS190 Functional Programming Techniques Dr Hans Georg Schaathun University of Surrey Autumn 2008 Week 1 Dr Hans Georg Schaathun Getting started with Hugs on Linux Autumn

More information

Week - 01 Lecture - 04 Downloading and installing Python

Week - 01 Lecture - 04 Downloading and installing Python Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and

More information

Linux File System and Basic Commands

Linux File System and Basic Commands Linux File System and Basic Commands 0.1 Files, directories, and pwd The GNU/Linux operating system is much different from your typical Microsoft Windows PC, and probably looks different from Apple OS

More information

Introduction to MatLab. Introduction to MatLab K. Craig 1

Introduction to MatLab. Introduction to MatLab K. Craig 1 Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations

More information

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline MATLAB Tutorial EE351M DSP Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Kitaek Bae Outline Part I: Introduction and Overview Part II: Matrix manipulations and common functions Part III: Plots

More information

Lab 1: Setup 12:00 PM, Sep 10, 2017

Lab 1: Setup 12:00 PM, Sep 10, 2017 CS17 Integrated Introduction to Computer Science Hughes Lab 1: Setup 12:00 PM, Sep 10, 2017 Contents 1 Your friendly lab TAs 1 2 Pair programming 1 3 Welcome to lab 2 4 The file system 2 5 Intro to terminal

More information

Programming Studio #1 ECE 190

Programming Studio #1 ECE 190 Programming Studio #1 ECE 190 Programming Studio #1 Announcements Recitation Binary representation, hexadecimal notation floating point representation, 2 s complement In Studio Assignment Introduction

More information

Intro to HPC Exercise

Intro to HPC Exercise Intro to HPC Exercise Lab Exercise: Introduction to HPC The assumption is that you have already tested your Amazon Web Service Elastic Compute Cloud (EC2) virtual machines chosen for the LCI hands on exercises.

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction: MATLAB is a powerful high level scripting language that is optimized for mathematical analysis, simulation, and visualization. You can interactively solve problems

More information

Functions. Systems Programming Concepts

Functions. Systems Programming Concepts Functions Systems Programming Concepts Functions Simple Function Example Function Prototype and Declaration Math Library Functions Function Definition Header Files Random Number Generator Call by Value

More information