ERTH2020 Introduction to Geophysics

Size: px
Start display at page:

Download "ERTH2020 Introduction to Geophysics"

Transcription

1 ERTH2020 Practical:: Introduction to Python Page 1 ERTH2020 Introduction to Geophysics 2018 Practical 1: Introduction to scientific programming using Python, and revision of basic mathematics Purposes To introduce simple programming skills using the popular Python language. To provide analysis tools for use in subsequent practicals. To encourage revision of basic mathematical ideas (algebra, trig, calculus) Report Required Exercises 1-7 are intended to guide you through introductory Python concepts. It is assumed that you are reasonably familiar with this material from the prerequisites for this course. No reporting is required for these parts. Your submitted report will concisely cover Exercises 8,9,10. Include your worked answers to mathematical elements, python code and output plots. Mathematical answers can be hand written. Mathematical Revision This practical provides a computational partner to ERTH2020 Tutorial 1 Basic Maths Revision. Two of the questions from that tutorial are repeated here and are to be included in this practical report.

2 ERTH2020 Practical:: Introduction to Python Page 2 Programming languages Most students will have had some experience with the concept of programming, via programmable calculators, or using the formula tool in Excel. These are useful for very simple tasks, but for realworld data handling more complete tools are needed. In geophysical modelling and data handling, several languages are currently being used, including: Fortran: Excellent for mathematical algorithms, easy to write and understand, produces 'fastest' code, huge archive of freely available code. Excellent open source versions available. C: Very powerful for low-level instrumental control, also widely used for algorithmic work, slightly more difficult to write, excellent general purpose language. Open Source available. C++ An update of 'C'. More powerful, but more difficult to learn, write and maintain. Matlab: Higher-level, hence excellent for rapid prototyping, but arguably less flexible and lower performance. Generally not used for production systems. Proprietary. Python: A modern, easy-to-use language with a rapidly growing support base. More detail below. Why use Python Very easy to learn, use and maintain Open-source Concise (fewer lines of code to do tasks) - economical to write and maintain High-level, very rapid development Good tools to link in existing Fortran or C code Excellent for User Interfaces and graphics. Python Versions As of 2018 there are two main version of Python in widespread use (Python 2.7 and Python 3.6). The differences are fairly minor, but code is not generally interchangeable. Some of the plotting tools we use are not yet stable in Python 3.6. Hence in this course we will use Python 2.7 Python Download URLs (if you want to install on your computer) The core Python language is freely available from This is the core distribution supporting most general purpose programming needs. However, there are three add-ons which are needed for our more specialised work. These are matplotlib, numpy and scipy, which are all freely available. As of 2018, one of the most convenient distributions which includes all these packages appears to be Anaconda, which is freely available at: You can download for Windows, MAC, or Linux. You can install either Python 2.7 or Python 3.x (or both.)

3 ERTH2020 Practical:: Introduction to Python Page 3 Python Tutorials We will outline all that we need in class. However, there are several good tutorials on the web if you want to go further. A good intro for beginners Python. the definitive tutorial by Guido van Rossum, the inventor of Note that in this course we adopt a programming approach which is relatively simple, but which allows you to do most of what is commonly needed in scientific computing. As you gain more experience Python allows you to explore more advanced approaches if you want to (e.g. NUMPY vector programming, object orientation etc.) Note on subtle differences between different python installs You may find differences between the interface on the UQ lab computers and other Python distributions. For uniformity we will use the standard IDLE interface, which is available on lab computers and also in Anaconda. Note on File Extensions In serious computational work, it is very useful to use the file extension to identify files of a particular type. For example, we will use the extension.py to signify a file which holds python code. Before proceeding ensure that your PC is configured so that it does NOT hide file extensions. This is important. Getting up and running in UQ Labs (Room 221/222) (Instructions for 2018) Log into windows Click on the window symbol at bottom left of the screen Type idle to search for the required program Select idle (Python GUI) You will get the Python interpreter prompt >>> You will also see confirmation that it is Version

4 ERTH2020 Practical:: Introduction to Python Page 4 Exercise 1: Using the Python Interpreter as a calculator As a starting point, we will work directly with the Python Interpreter. This is very useful for understanding how individual Python statements are interpreted. Start up the Python IDLE interpreter as described at bottom of Page 3 On IDLE, you will see the Python interpreter prompt >>> In the following, italics are used to indicate what you should type in after the prompt (>>>) (a) Try typing some simple mathematical expressions, such as: * * * ( ) 3 / 2 (what is going on here!). Note that this convention has changed in Python /2 (b) Experiment with spaces, brackets, minus signs etc. Does the interpreter behave as expected? (c) Experiment with some simple algebra, such as: a = 10.0 b = 20.0 a + b c= a+b c d=a**2+b**2+c**2 D what happens and why?

5 ERTH2020 Practical:: Introduction to Python Page 5 Exercise 2: Importing modules into the Interpreter - mathematical functions (a) Experiment with some mathematical functions. sin (0) log (100.0) x=pi/2 what happens and why? (b) Now tell the interpreter to load the maths module and experiment further. from math import sin, pi, log sin (0) sin 0 note that you need the brackets in a function sin (90) what happens and why? sin(pi/2) python needs angles in radians. Python knows about pi log(100) assumes natural log log10(100) special function for base 10 log(100,e) more general usage. See what happens when you stop typing after the '(' log(100,10) dir() shows you what names and functions you currently have available Exercise 3: Experimenting with useful control functions (a) Experiment with the range function, noting in particular, the behaviour of the 'end' point. range(1,10) range(1,10,2) produces a list of integers, but excludes the 'end' point increment other than 1 is allowed. (b) Experiment with the multi-line 'for' statement. for i in range(0,5): print i, 'squared is', i**2 note the colon note the indentation - very important note quotes and commas in print statement (c) Experiment with the multi-line 'if' statement. x=5 if x>0: print 'x is greater than zero' note the indentation. Try again but with x = -3

6 ERTH2020 Practical:: Introduction to Python Page 6 Exercise 4: Python Program sinwave1.py Now that we understand how the interpreter works, we can try some more interesting exercises. We will want to save our efforts, and the way we do this is to put all our commands into a file. From the IDLE Shell, click on file, new window. Immediately Save as sinwave1.py, in a sensible directory of your own. Note that the.py extension tells the editor that we are typing a python program, and we will immediately get nice colours etc. (Note as discussed previously we are assuming you are NOT hiding file extensions if you are you'll get into serious confusion about now.) Then enter the following code and save. program sinwave1.py compute a sinwave for i in range(0,91,1): theta = i * pi / print 'sin', i, 'is ', sin (theta) step through angle in degrees convert to radians Click on Run, Run Module and see what happens. Fix your program by adding an import command and rerun. Exercise 5: Python Program sinwave2.py- Introducing Arrays Start with your sinwave1.py program, and do a save as sinwave2.py This will do exactly the same thing, but now we are using arrays, which will make it easier when we come to plotting. program sinwave2.py compute sin wave using arrays from math import pi, sin from numpy import zeros sinwave = zeros (1000, float) for i in range(0,91,1): theta = i * pi / sinwave[i] = sin(theta) print 'sin', i, 'is ', sinwave[i] load general maths tools load array tools set up a numpy array for answers step through angle in degrees convert to radians

7 ERTH2020 Practical:: Introduction to Python Page 7 Exercise 6: Python Program sincos.py - Introducing Plotting Do a save-as on your previous code, and modify it to make a new program We ll call it sincos.py program sincos.py compute and plot sin and cos waves using arrays from math import sin, cos, pi load general maths tools from numpy import zeros load array tools from pylab import plot, title, xlabel, ylabel, legend, show plotting tools sinwave = zeros (91, float) set up arrays for answers coswave = zeros (91,float) for i in range(0,91,1): step through angle in degrees theta = i * pi / convert to radians sinwave[i] = sin(theta) coswave[i]=cos(theta) print 'Angle:', i, 'Sin:', sinwave[i], 'Cos:', coswave[i] plot (sinwave, label='sin') Now plot the functions plot (coswave, label='cos') title('trig Function Plot') xlabel('angle (deg)') ylabel('function') legend() show() Note: The following four exercises are to be submitted. They will be due on Tuesday in Week 3. To ensure maximum marks, make sure you answer everything that is asked. By the end of Exercise 10 you'll be a competent Python programmer. Exercise 7: The plotting mechanism in Exercise 6 is limited in that the 'degrees axis' can only handle positive latitudes, and unit increments. Improve the program to plot from to 90.0 degrees at an increment of 0.1 degrees. One way to achieve this is to introduce a new array for the latitude. This then requires a slightly different plot command of the form: plot(latitude, sinwave, label='sin') One mechanism to handle this type of double sided plotting (-90.0 to 90.0) is given in Exercise 10. From now on we will normally use two arrays whenever we do xy type plots. This allows us to handle increments other than 1 on the x axis.

8 ERTH2020 Practical:: Introduction to Python Page 8 Exercise 8: Beach Problem A Note: This question and the following one are repeated from Tutorial 1. They provide good revision of several mathematical ideas, as well as practice in Python. We will do the programming elements in our practical class. In your report include all elements. Maths can be hand written. I have arrived at the gate to the beach (Point G on the accompanying plan-view diagram) and I want to walk to Point S, 100m along the beach, where the surf looks good. On the soft sand I can walk at 2.5 km/hr. On the hard sand (right at the waters edge) I can walk at 5 km/hr. I want to get to the surf as quickly as possible! 100 m Water S P x Hard sand (vh=5km/hr) 50m Soft sand (vs=2.5km/hr) Fence G (i) Use calculus to show that the take-off direction ( ) which will give the shortest possible time is approximately 30 degrees, and that the time taken is then approximately seconds. [Method 1: Express the total time as a function of x, minimise with respect to x, and finally find (ii) Repeat Part (i) but now derive your time equation directly as a function of and then differentiate with respect to (iii) Use a numerical approach to confirm your optimum value. [ Method: Using Python plot the total time from G to P to S as a function of Read off the optimum value, and the corresponding travel time.] (iv) Which approach (analytical or numerical) do you prefer and why?

9 ERTH2020 Practical:: Introduction to Python Page 9 Exercise 9: Beach Problem B The following weekend, I visit the same location at low tide, such that the water is now 50m further out. I now have to walk obliquely across the hard sand to get to the surf. Surf S 100 m Hard sand (vh=5km/hr) 50m P x Soft sand (vs=2.5 km/hr) Fence G 50m (i) Use a numerical approach to show that the take-off direction ( ) which will give the shortest time along the path GPS is approximately 24.8 degrees. Show that the corresponding shortest time is about 145.4s. (ii) Using calculus (method from 8(i)) show that the x value corresponding to this optimum path satisfies the following 4th order equation x x x x = 0 (Depending on how you handle the problem you may get an equation which is just a multiple of this one. That is OK since the RHS is zero.) (iii) Plot the polynomial in (ii) as a function of x (use Python). Show that the polynomial has a root at x = 23.09m. Hence show that the corresponding travel time and takeoff direction agree with your numerical solution in Part (i) (iv) Use the Wolfram Alpha website to confirm the root of your polynomial in (ii) (v) The increased complexity of Exercise 9 compared to Exercise 8 means that the numerical approach is probably easier for most people. However the analytical solution also has a very important role. What might this be?

10 ERTH2020 Practical:: Introduction to Python Page 10 Exercise 10: Vertical gravity anomaly due to a buried spherical body This final exercise is intended to provide additional practice in python programming. It is designed to include the same programming constructs as in Exercises 8-9, applied to a different geophysical problem. The results from this exercise will be used in Practical 2. This exercise is intended to be completed outside of class. Background theory The required theory can be easily understood with reference to several basic concepts. The following outline essentially summarises upcoming lecture material from ERTH2020. If a buried body can be approximated as a sphere, then we can calculate the gravity anomaly using an analytical approach. That is, we use a theoretical formula derived by the volume-integration approach. When the integration process is carried through, we find that a spherical body behaves as if it were a particle-sized body with its mass at the centre of the sphere. Suppose the spherical body has a radius R and density contrast (relative to the country rock) The anomalous mass will therefore be M = 4 R 3 / 3 (Volume x density contrast) (1) The gravity anomaly at a distance r from the centre of the sphere is then dg = G M / r 2 (2) Suppose that the centre of the sphere is at a depth Z. Consider a surface observation point at a horizontal distance x from the centre of the sphere. That is, the distance from centre of sphere to observation point, by Pythagoras theorem is given by Hence r 2 = x 2 + Z 2 dg = G M / ( x 2 + Z 2 ) (3) Normally we are interested in the vertical component of gravity. dg Z = G M cos / ( x 2 + Z 2 ) = G M (Z / r) / ( x 2 + Z 2 ) dg Z = G M Z / (x 2 + Z 2 ) 3/2 (4)

11 ERTH2020 Practical:: Introduction to Python Page 11 Exercise 10 - Instructions Assume a spherical body of radius R= 50m, depth to centre Z=100m, and density contrast =1000 kg m -3. Using Equations 1 and 4, calculate and plot the gravity anomaly (i.e. the excess gravitational acceleration in m s -2 ) along a surface profile extending from x =- 300m to x = 300m at an interval of 1m. The basic code here will be similar to that used in Exercises 8,9. Some coding ideas to get you started are given below. Demonstrate the concept of non-uniqueness, by choosing new values of R and which yield the same gravity anomaly curve. Hint: look at Equation 1. How do you need to change R and, so as to keep the same anomalous mass M. In Practical 2, you will check your Python curves using the Berkeley web modeller. Coding Ideas for Ex 10 (Note that the following code is incomplete) : sphere.py gravity anomaly due to a buried spherical body from math import... from numpy import. from pylab import... define the model parameters G =. Big G in SI units R =50.0 radius of sphere in m Z =100.0 depth to centre in m sigma = density contrast in SI units N= 601 number of points on the profile (from -300m to 300m at 1m intervals) dx=1.0 x increment in m initialise arrays x= zeros(n, float) array to hold x coordinate for the plot dgz= zeros(... array to hold the computed gravity anomaly calculate excess mass M =... use Equation 1 loop along the profile at 1m interval for i in range(0,n): x[i] = i*dx the x coordinate dgz[i] =... use Eqn 4 here plot(x,dgz) now plot the gravity anomaly title(... xlabel(... ylabel(... show()

ERTH3021 Exploration and Mining Geophysics

ERTH3021 Exploration and Mining Geophysics ERTH3021 Exploration and Mining Geophysics Practical 1: Introduction to Scientific Programming using Python Purposes To introduce simple programming skills using the popular Python language. To provide

More information

1 Introduction. 2 Useful linear algebra (reprise) Introduction to MATLAB Reading. Spencer and Ware (2008), secs. 1-7, 9-9.3,

1 Introduction. 2 Useful linear algebra (reprise) Introduction to MATLAB Reading. Spencer and Ware (2008), secs. 1-7, 9-9.3, Introduction to MATLAB Reading Spencer and Ware (2008), secs. 1-7, 9-9.3, 12-12.4. For reference: matlab online help desk 1 Introduction MATLAB is commercial software that provides a computing environment

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

3 Introduction to MATLAB

3 Introduction to MATLAB 3 Introduction to MATLAB 3 INTRODUCTION TO MATLAB 3.1 Reading Spencer and Ware 2008), secs. 1-7, 9-9.3, 12-12.4. For reference: Matlab online help desk 3.2 Introduction Matlab is a commercial software

More information

Geophysics 224 B2. Gravity anomalies of some simple shapes. B2.1 Buried sphere

Geophysics 224 B2. Gravity anomalies of some simple shapes. B2.1 Buried sphere Geophysics 4 B. Gravity anomalies of some simple shapes B.1 Buried sphere Gravity measurements are made on a surface profile across a buried sphere. The sphere has an excess mass M S and the centre is

More information

Scientific Computing using Python

Scientific Computing using Python Scientific Computing using Python Swaprava Nath Dept. of CSE IIT Kanpur mini-course webpage: https://swaprava.wordpress.com/a-short-course-on-python/ Disclaimer: the contents of this lecture series are

More information

Getting Started with MATLAB

Getting Started with MATLAB Getting Started with MATLAB Math 315, Fall 2003 Matlab is an interactive system for numerical computations. It is widely used in universities and industry, and has many advantages over languages such as

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

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs).

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs). L A B 6 M A T L A B MATLAB INTRODUCTION Matlab is a commercial product that is used widely by students and faculty and researchers at UTEP. It provides a "high-level" programming environment for computing

More information

MATH STUDENT BOOK. 12th Grade Unit 4

MATH STUDENT BOOK. 12th Grade Unit 4 MATH STUDENT BOOK th Grade Unit Unit GRAPHING AND INVERSE FUNCTIONS MATH 0 GRAPHING AND INVERSE FUNCTIONS INTRODUCTION. GRAPHING 5 GRAPHING AND AMPLITUDE 5 PERIOD AND FREQUENCY VERTICAL AND HORIZONTAL

More information

Introduction to MATLAB Practical 1

Introduction to MATLAB Practical 1 Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior

More information

(Ca...

(Ca... 1 of 8 9/7/18, 1:59 PM Getting started with 228 computational exercises Many physics problems lend themselves to solution methods that are best implemented (or essentially can only be implemented) with

More information

Introduction to Python Practical 1

Introduction to Python Practical 1 Introduction to Python Practical 1 Daniel Carrera & Brian Thorsbro October 2017 1 Introduction I believe that the best way to learn programming is hands on, and I tried to design this practical that way.

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 13 Revision Notes CAV review Topics Covered Sample

More information

An Introduction to Maple and Maplets for Calculus

An Introduction to Maple and Maplets for Calculus An Introduction to Maple and Maplets for Calculus Douglas B. Meade Department of Mathematics University of South Carolina Columbia, SC 29208 USA URL: www.math.sc.edu/~meade e-mail: meade@math.sc.edu Philip

More information

MEI Desmos Tasks for AS Pure

MEI Desmos Tasks for AS Pure Task 1: Coordinate Geometry Intersection of a line and a curve 1. Add a quadratic curve, e.g. y = x² 4x + 1 2. Add a line, e.g. y = x 3 3. Select the points of intersection of the line and the curve. What

More information

A quick Matlab tutorial

A quick Matlab tutorial A quick Matlab tutorial Michael Robinson 1 Introduction In this course, we will be using MATLAB for computer-based matrix computations. MATLAB is a programming language/environment that provides easy access

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

Working Environment : Python #1

Working Environment : Python #1 Working Environment : Python #1 Serdar ARITAN Biomechanics Research Group, Faculty of Sports Sciences, and Department of Computer Graphics Hacettepe University, Ankara, Turkey 1 Physics has several aspects:

More information

Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 5/17/2012 Physics 120 Section: ####

Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 5/17/2012 Physics 120 Section: #### Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 Lab partners: Lab#1 Presentation of lab reports The first thing we do is to create page headers. In Word 2007 do the following:

More information

Introduction to Python Part 1. Brian Gregor Research Computing Services Information Services & Technology

Introduction to Python Part 1. Brian Gregor Research Computing Services Information Services & Technology Introduction to Python Part 1 Brian Gregor Research Computing Services Information Services & Technology RCS Team and Expertise Our Team Scientific Programmers Systems Administrators Graphics/Visualization

More information

EE 301 Signals & Systems I MATLAB Tutorial with Questions

EE 301 Signals & Systems I MATLAB Tutorial with Questions EE 301 Signals & Systems I MATLAB Tutorial with Questions Under the content of the course EE-301, this semester, some MATLAB questions will be assigned in addition to the usual theoretical questions. This

More information

Lab 1 Intro to MATLAB and FreeMat

Lab 1 Intro to MATLAB and FreeMat Lab 1 Intro to MATLAB and FreeMat Objectives concepts 1. Variables, vectors, and arrays 2. Plotting data 3. Script files skills 1. Use MATLAB to solve homework problems 2. Plot lab data and mathematical

More information

0 Graphical Analysis Use of Excel

0 Graphical Analysis Use of Excel Lab 0 Graphical Analysis Use of Excel What You Need To Know: This lab is to familiarize you with the graphing ability of excels. You will be plotting data set, curve fitting and using error bars on the

More information

Laboratory 1 Octave Tutorial

Laboratory 1 Octave Tutorial Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory

More information

CSI Lab 02. Tuesday, January 21st

CSI Lab 02. Tuesday, January 21st CSI Lab 02 Tuesday, January 21st Objectives: Explore some basic functionality of python Introduction Last week we talked about the fact that a computer is, among other things, a tool to perform high speed

More information

Lab1: Use of Word and Excel

Lab1: Use of Word and Excel Dr. Fritz Wilhelm; physics 230 Lab1: Use of Word and Excel Page 1 of 9 Lab partners: Download this page onto your computer. Also download the template file which you can use whenever you start your lab

More information

The value of f(t) at t = 0 is the first element of the vector and is obtained by

The value of f(t) at t = 0 is the first element of the vector and is obtained by MATLAB Tutorial This tutorial will give an overview of MATLAB commands and functions that you will need in ECE 366. 1. Getting Started: Your first job is to make a directory to save your work in. Unix

More information

Get It Interpreter Scripts Arrays. Basic Python. K. Cooper 1. 1 Department of Mathematics. Washington State University. Basics

Get It Interpreter Scripts Arrays. Basic Python. K. Cooper 1. 1 Department of Mathematics. Washington State University. Basics Basic Python K. 1 1 Department of Mathematics 2018 Python Guido van Rossum 1994 Original Python was developed to version 2.7 2010 2.7 continues to receive maintenance New Python 3.x 2008 The 3.x version

More information

Math 2250 Lab #3: Landing on Target

Math 2250 Lab #3: Landing on Target Math 2250 Lab #3: Landing on Target 1. INTRODUCTION TO THE LAB PROGRAM. Here are some general notes and ideas which will help you with the lab. The purpose of the lab program is to expose you to problems

More information

Computer Lab 1: Introduction to Python

Computer Lab 1: Introduction to Python Computer Lab 1: Introduction to Python 1 I. Introduction Python is a programming language that is fairly easy to use. We will use Python for a few computer labs, beginning with this 9irst introduction.

More information

MS6021 Scientific Computing. TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing

MS6021 Scientific Computing. TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing MS6021 Scientific Computing TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing Preliminary Notes on Python (v MatLab + other languages) When you enter Spyder (available on installing Anaconda),

More information

Matlab Tutorial and Exercises for COMP61021

Matlab Tutorial and Exercises for COMP61021 Matlab Tutorial and Exercises for COMP61021 1 Introduction This is a brief Matlab tutorial for students who have not used Matlab in their programming. Matlab programming is essential in COMP61021 as a

More information

How to learn MATLAB? Some predefined variables

How to learn MATLAB? Some predefined variables ECE-S352 Lab 1 MATLAB Tutorial How to learn MATLAB? 1. MATLAB comes with good tutorial and detailed documents. a) Select MATLAB help from the MATLAB Help menu to open the help window. Follow MATLAB s Getting

More information

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window. EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses

More information

Computer Science 102. Into to Computational Modeling Special Topics: Programming in Matlab

Computer Science 102. Into to Computational Modeling Special Topics: Programming in Matlab Computer Science 102 Into to Computational Modeling Special Topics: Programming in Matlab Matlab An integrated programming and graphical environment Interpreted : interactive; get answer immediately Also

More information

COSC 490 Computational Topology

COSC 490 Computational Topology COSC 490 Computational Topology Dr. Joe Anderson Fall 2018 Salisbury University Course Structure Weeks 1-2: Python and Basic Data Processing Python commonly used in industry & academia Weeks 3-6: Group

More information

Lecture 1. Course Overview, Python Basics

Lecture 1. Course Overview, Python Basics Lecture 1 Course Overview, Python Basics We Are Very Full! Lectures and Labs are at fire-code capacity We cannot add sections or seats to lectures You may have to wait until someone drops No auditors are

More information

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018 Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from

More information

f( x ), or a solution to the equation f( x) 0. You are already familiar with ways of solving

f( x ), or a solution to the equation f( x) 0. You are already familiar with ways of solving The Bisection Method and Newton s Method. If f( x ) a function, then a number r for which f( r) 0 is called a zero or a root of the function f( x ), or a solution to the equation f( x) 0. You are already

More information

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System CHAPTER 1 INTRODUCTION Digital signal processing (DSP) technology has expanded at a rapid rate to include such diverse applications as CDs, DVDs, MP3 players, ipods, digital cameras, digital light processing

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

Pre-Lab Excel Problem

Pre-Lab Excel Problem Pre-Lab Excel Problem Read and follow the instructions carefully! Below you are given a problem which you are to solve using Excel. If you have not used the Excel spreadsheet a limited tutorial is given

More information

Introduction to Scientific Computing with Matlab

Introduction to Scientific Computing with Matlab Introduction to Scientific Computing with Matlab Matlab is an interactive system for numerical computations. It is widely used in universities and industry, and has many advantages over languages such

More information

Lab1: Communicating science

Lab1: Communicating science Lab1: Communicating science We would all like to be good citizens of the scientific community. An important part of being a good citizen is being able to communicate results, papers, and ideas. Since many

More information

ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20

ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20 page 1 of 9 ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20 Steve Norman Department of Electrical & Computer Engineering University of Calgary November 2017 Lab instructions and

More information

New Mexico Tech Hyd 510

New Mexico Tech Hyd 510 Numerics Motivation Modeling process (JLW) To construct a model we assemble and synthesize data and other information to formulate a conceptual model of the situation. The model is conditioned on the science

More information

Goals: Course Unit: Describing Moving Objects Different Ways of Representing Functions Vector-valued Functions, or Parametric Curves

Goals: Course Unit: Describing Moving Objects Different Ways of Representing Functions Vector-valued Functions, or Parametric Curves Block #1: Vector-Valued Functions Goals: Course Unit: Describing Moving Objects Different Ways of Representing Functions Vector-valued Functions, or Parametric Curves 1 The Calculus of Moving Objects Problem.

More information

Physics 251 Laboratory Introduction to Spreadsheets

Physics 251 Laboratory Introduction to Spreadsheets Physics 251 Laboratory Introduction to Spreadsheets Pre-Lab: Please do the lab-prep exercises on the web. Introduction Spreadsheets have a wide variety of uses in both the business and academic worlds.

More information

Lecture 1. Course Overview, Python Basics

Lecture 1. Course Overview, Python Basics Lecture 1 Course Overview, Python Basics We Are Very Full! Lectures are at fire-code capacity. We cannot add sections or seats to lectures You may have to wait until someone drops No auditors are allowed

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

Laboratory 1 Introduction to MATLAB for Signals and Systems

Laboratory 1 Introduction to MATLAB for Signals and Systems Laboratory 1 Introduction to MATLAB for Signals and Systems INTRODUCTION to MATLAB MATLAB is a powerful computing environment for numeric computation and visualization. MATLAB is designed for ease of use

More information

MATLAB TUTORIAL WORKSHEET

MATLAB TUTORIAL WORKSHEET MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent

More information

The Bisection Method versus Newton s Method in Maple (Classic Version for Windows)

The Bisection Method versus Newton s Method in Maple (Classic Version for Windows) The Bisection Method versus (Classic Version for Windows) Author: Barbara Forrest Contact: baforres@uwaterloo.ca Copyrighted/NOT FOR RESALE version 1.1 Contents 1 Objectives for this Lab i 2 Approximate

More information

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Using Monte Carlo to Estimate π using Buffon s Needle Problem An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s. Here s the problem (in a simplified form). Suppose

More information

Research Computing with Python, Lecture 1

Research Computing with Python, Lecture 1 Research Computing with Python, Lecture 1 Ramses van Zon SciNet HPC Consortium November 4, 2014 Ramses van Zon (SciNet HPC Consortium)Research Computing with Python, Lecture 1 November 4, 2014 1 / 35 Introduction

More information

MATLAB Tutorial III Variables, Files, Advanced Plotting

MATLAB Tutorial III Variables, Files, Advanced Plotting MATLAB Tutorial III Variables, Files, Advanced Plotting A. Dealing with Variables (Arrays and Matrices) Here's a short tutorial on working with variables, taken from the book, Getting Started in Matlab.

More information

MAT 275 Laboratory 1 Introduction to MATLAB

MAT 275 Laboratory 1 Introduction to MATLAB MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory

More information

Molecular Statistics Exercise 1. As was shown to you this morning, the interactive python shell can add, subtract, multiply and divide numbers.

Molecular Statistics Exercise 1. As was shown to you this morning, the interactive python shell can add, subtract, multiply and divide numbers. Molecular Statistics Exercise 1 Introduction This is the first exercise in the course Molecular Statistics. The exercises in this course are split in two parts. The first part of each exercise is a general

More information

Symbols. Anscombe s quartet, antiderivative, 200. bar charts for exercise, for expenses, Barnsley fern, drawing,

Symbols. Anscombe s quartet, antiderivative, 200. bar charts for exercise, for expenses, Barnsley fern, drawing, Index Symbols + (addition operator), 2 {} (curly brackets), to define a set, 122 δ (delta), 184 / (division operator), 2 ε (epsilon), 192, 197 199 == (equality operator), 124 e (Euler s number), 179 **

More information

1 Introduction to Matlab

1 Introduction to Matlab 1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,

More information

Dynamics and Vibrations Mupad tutorial

Dynamics and Vibrations Mupad tutorial Dynamics and Vibrations Mupad tutorial School of Engineering Brown University ENGN40 will be using Matlab Live Scripts instead of Mupad. You can find information about Live Scripts in the ENGN40 MATLAB

More information

Models for Nurses: Quadratic Model ( ) Linear Model Dx ( ) x Models for Doctors:

Models for Nurses: Quadratic Model ( ) Linear Model Dx ( ) x Models for Doctors: The goal of this technology assignment is to graph several formulas in Excel. This assignment assumes that you using Excel 2007. The formula you will graph is a rational function formed from two polynomials,

More information

Introduction to Python Part 2

Introduction to Python Part 2 Introduction to Python Part 2 v0.2 Brian Gregor Research Computing Services Information Services & Technology Tutorial Outline Part 2 Functions Tuples and dictionaries Modules numpy and matplotlib modules

More information

User-Defined Function

User-Defined Function ENGR 102-213 (Socolofsky) Week 11 Python scripts In the lecture this week, we are continuing to learn powerful things that can be done with userdefined functions. In several of the examples, we consider

More information

Introduction to Python for Scientific Computing

Introduction to Python for Scientific Computing 1 Introduction to Python for Scientific Computing http://tinyurl.com/cq-intro-python-20151022 By: Bart Oldeman, Calcul Québec McGill HPC Bart.Oldeman@calculquebec.ca, Bart.Oldeman@mcgill.ca Partners and

More information

Introduction to Finite Element Modelling in Geosciences: Introduction to MATLAB

Introduction to Finite Element Modelling in Geosciences: Introduction to MATLAB Introduction to Finite Element Modelling in Geosciences: Introduction to MATLAB D. A. May & M. Frehner ETH Zürich July 7, 2014 1 Introduction This main goal of this part of the course is to learn how to

More information

FIND RECTANGULAR COORDINATES FROM POLAR COORDINATES CALCULATOR

FIND RECTANGULAR COORDINATES FROM POLAR COORDINATES CALCULATOR 29 June, 2018 FIND RECTANGULAR COORDINATES FROM POLAR COORDINATES CALCULATOR Document Filetype: PDF 464.26 KB 0 FIND RECTANGULAR COORDINATES FROM POLAR COORDINATES CALCULATOR Rectangular to Polar Calculator

More information

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies

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

ENGG1811 Computing for Engineers Week 1 Introduction to Programming and Python

ENGG1811 Computing for Engineers Week 1 Introduction to Programming and Python ENGG1811 Computing for Engineers Week 1 Introduction to Programming and Python ENGG1811 UNSW, CRICOS Provider No: 00098G W4 Computers have changed engineering http://www.noendexport.com/en/contents/48/410.html

More information

Writing MATLAB Programs

Writing MATLAB Programs Outlines September 14, 2004 Outlines Part I: Review of Previous Lecture Part II: Review of Previous Lecture Outlines Part I: Review of Previous Lecture Part II: Control Structures If/Then/Else For Loops

More information

Here is the data collected.

Here is the data collected. Introduction to Scientific Analysis of Data Using Spreadsheets. Computer spreadsheets are very powerful tools that are widely used in Business, Science, and Engineering to perform calculations and record,

More information

Handout: Handy Computer Tools

Handout: Handy Computer Tools Handout: Handy Computer Tools T. Satogata: January 2017 USPAS Accelerator Physics January 2017 This is a description of a few computational tools that I ve found to be useful as a working physicist. This

More information

3.4 System Dynamics Tool: Nova Tutorial 2. Introduction to Computational Science: Modeling and Simulation for the Sciences

3.4 System Dynamics Tool: Nova Tutorial 2. Introduction to Computational Science: Modeling and Simulation for the Sciences 3.4 System Dynamics Tool: Nova Tutorial 2 Introduction to Computational Science: Modeling and Simulation for the Sciences Angela B. Shiflet and George W. Shiflet Wofford College 2006 by Princeton University

More information

Programming with Python

Programming with Python Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2

More information

Class #15: Experiment Introduction to Matlab

Class #15: Experiment Introduction to Matlab Class #15: Experiment Introduction to Matlab Purpose: The objective of this experiment is to begin to use Matlab in our analysis of signals, circuits, etc. Background: Before doing this experiment, students

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

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

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB? Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system

More information

Python Programming. Hans-Petter Halvorsen.

Python Programming. Hans-Petter Halvorsen. Python Programming Hans-Petter Halvorsen https://www.halvorsen.blog Python Programming Python Programming Hans-Petter Halvorsen 2018 Python Programming c Hans-Petter Halvorsen December 20, 2018 1 Preface

More information

LAB 2: DATA FILTERING AND NOISE REDUCTION

LAB 2: DATA FILTERING AND NOISE REDUCTION NAME: LAB TIME: LAB 2: DATA FILTERING AND NOISE REDUCTION In this exercise, you will use Microsoft Excel to generate several synthetic data sets based on a simplified model of daily high temperatures in

More information

Output Primitives Lecture: 4. Lecture 4

Output Primitives Lecture: 4. Lecture 4 Lecture 4 Circle Generating Algorithms Since the circle is a frequently used component in pictures and graphs, a procedure for generating either full circles or circular arcs is included in most graphics

More information

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar

More information

Administrivia. Next Monday is Thanksgiving holiday. Tuesday and Wednesday the lab will be open for make-up labs. Lecture as usual on Thursday.

Administrivia. Next Monday is Thanksgiving holiday. Tuesday and Wednesday the lab will be open for make-up labs. Lecture as usual on Thursday. Administrivia Next Monday is Thanksgiving holiday. Tuesday and Wednesday the lab will be open for make-up labs. Lecture as usual on Thursday. Lab notebooks will be due the week after Thanksgiving, when

More information

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections 6.189 Day 3 Today there are no written exercises. Turn in your code tomorrow, stapled together, with your name and the file name in comments at the top as detailed in the Day 1 exercises. Readings How

More information

Week Two. Arrays, packages, and writing programs

Week Two. Arrays, packages, and writing programs Week Two Arrays, packages, and writing programs Review UNIX is the OS/environment in which we work We store files in directories, and we can use commands in the terminal to navigate around, make and delete

More information

MEI GeoGebra Tasks for AS Pure

MEI GeoGebra Tasks for AS Pure Task 1: Coordinate Geometry Intersection of a line and a curve 1. Add a quadratic curve, e.g. y = x 2 4x + 1 2. Add a line, e.g. y = x 3 3. Use the Intersect tool to find the points of intersection of

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

Math Day 2 Programming: How to make computers do math for you

Math Day 2 Programming: How to make computers do math for you Math Day 2 Programming: How to make computers do math for you Matt Coles February 10, 2015 1 Intro to Python (15min) Python is an example of a programming language. There are many programming languages.

More information

Introduction to Python and NumPy I

Introduction to Python and NumPy I Introduction to Python and NumPy I This tutorial is continued in part two: Introduction to Python and NumPy II Table of contents Overview Launching Canopy Getting started in Python Getting help Python

More information

Chapter P Preparation for Calculus

Chapter P Preparation for Calculus Chapter P Preparation for Calculus Chapter Summary Section Topics P.1 Graphs and Models Sketch the graph of an equation. Find the intercepts of a graph. Test a graph for symmetry with respect to an axis

More information

Lagrange Multipliers and Problem Formulation

Lagrange Multipliers and Problem Formulation Lagrange Multipliers and Problem Formulation Steven J. Miller Department of Mathematics and Statistics Williams College Williamstown, MA 01267 Abstract The method of Lagrange Multipliers (and its generalizations)

More information

You are currently enrolled in IB Math SL for the Fall of This course will prepare you for the IB Math SL Exam in May of 2019.

You are currently enrolled in IB Math SL for the Fall of This course will prepare you for the IB Math SL Exam in May of 2019. Welcome to IB MATH SL! You are currently enrolled in IB Math SL for the Fall of 2018. This course will prepare you for the IB Math SL Exam in May of 2019. Prior to the Fall 2018 semester, you will need

More information

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example: Using MATLAB for Stochastic Simulation. Eric W. Hansen. Matlab Basics Introduction MATLAB (MATrix LABoratory) is a software package designed for efficient, reliable numerical computing. Using MATLAB greatly

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

Introduction. What is Maple? How to use this tutorial. Where can I find Maple?

Introduction. What is Maple? How to use this tutorial. Where can I find Maple? Introduction What is Maple? Maple is a computer program for people doing mathematics. Using Maple to do your calculations should make the work more interesting, allow you to focus more on the concepts,

More information

GG450 4/5/2010. Today s material comes from p and in the text book. Please read and understand all of this material!

GG450 4/5/2010. Today s material comes from p and in the text book. Please read and understand all of this material! GG450 April 6, 2010 Seismic Reflection I Today s material comes from p. 32-33 and 81-116 in the text book. Please read and understand all of this material! Back to seismic waves Last week we talked about

More information

Dr. Del's Tiers 1 6 Syllabus

Dr. Del's Tiers 1 6 Syllabus Tier 1 28 SCIENTIC CALCULATOR & PRE-ALGEBRA LESSONS Using a Scientific Calculator: Introduction plus 16 lessons CI: Introduction (5 Min.) C1: Basic Operations (6 Min.) C2: Real Numbers (6 Min.) C3: Negative

More information

Use Geometry Expressions to create and graph functions, and constrain points to functions.

Use Geometry Expressions to create and graph functions, and constrain points to functions. Learning Objectives Parametric Functions Lesson 1: Function Review Level: Algebra Time required: 30 minutes This is the first lesson in the unit on parametric functions. Parametric functions are not really

More information