An Introduction to Programming and Algorithms. Course Objectives A basic understanding of engineering problem solving process. A basic understanding of.

Slides:



Advertisements
Similar presentations
Motion in 2D o Vectors o Projectile Motion Physics -101 Piri Reis University 2010.
Advertisements

M 1 and M 2 – Masses of the two objects [kg] G – Universal gravitational constant G = 6.67x N m 2 /kg 2 or G = 3.439x10 -8 ft 4 /(lb s 4 ) r – distance.
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
Modelling - Module 1 Lecture 1 Modelling - Module 1 Lecture 1 David Godfrey.
Describing Motion with Equations There are a variety of quantities associated with the motion of objects – displacement (and distance), velocity (and speed),
Mathematics with vectors When dealing with more than one dimension, can have the same equation come up multiple times. Example: Position equation in three.
Projectile Motion.
Chapter 1 Computing Tools Data Representation, Accuracy and Precision Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
1 © 2010 Pearson Education, Inc. All rights reserved © 2010 Pearson Education, Inc. All rights reserved Chapter 4 Trigonometric Functions.
Parametric Equations Here are some examples of trigonometric functions used in parametric equations.
Chapter 3 Vectors.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
CSE123 Introduction to Computing Lecture 1 Introduction Engineering Problem Solving.
Physics 121 Topics: Course announcements Quiz
VECTORS The study of vectors is closely related to the study of such
Copyright © Cengage Learning. All rights reserved.
Unit 8 POE Ballistic Device
General Analysis Procedure and Calculator Policy Calculator Policy.
Dimensions of Physics. The essence of physics is to measure the observable world and describe the principles that underlie everything in creation. This.
 Must have a number and a UNIT  SI measurements.
Mathematical Processes GLE  I can identify the operations needed to solve a real-world problem.  I can write an equation to solve a real-world.
Chapter 8: Problem Solving
Copyright © Cengage Learning. All rights reserved.
SACE Stage 2 Physics Motion in 2 Dimensions.
Engineering Problem Solving Kuncicky – MatLab Programming G. Polya – How to Solve it.
Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Vectors and Parametric Equations
Software Life Cycle What Requirements Gathering, Problem definition
Physics Lesson 6 Projectile Motion Eleanor Roosevelt High School Mr. Chin-Sung Lin.
Slide 9- 1 Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CSE123 Introduction to Computing Lecture 1 – Introduction to Computers 1.
Copyright Sautter Motion in Two Dimension - Projectiles Projectile motion involves object that move up or down and right or left simultaneously.
Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright Sautter General Problem Solving Steps (1) Read the problem more than once (three of four times is preferable) (2) Decide what is to be.
Vector components and motion. There are many different variables that are important in physics. These variables are either vectors or scalars. What makes.
What is the magnitude and direction (if any) of the acceleration of the ball at the instant it reaches the highest point in its trajectory? What is its.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
Introduction to Loops For Loops. Motivation for Using Loops So far, everything we’ve done in MATLAB, you could probably do by hand: Mathematical operations.
Kinematics in Two Dimensions. Section 1: Adding Vectors Graphically.
PROJECTILE MOTION. Relevant Physics: The Independence of the Vertical and Horizontal directions means that a projectile motion problem consists of two.
College Physics Chapter 1 Introduction. Theories and Experiments The goal of physics is to develop theories based on experiments A theory is a “guess,”
Motion in Two Dimensions
The Hashemite University Computer Engineering Department
MECHANICS Ms. Peace Introduction. Sequence 1.1 What is Mechanics? 1.1 What is Mechanics? 1.2 Fundamental Concepts and Principles 1.2 Fundamental Concepts.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Calculating ‘g’ practical
General Analysis Procedure and Calculator Policy Calculator Policy.
Chapter Projectile Motion 6.1.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
PHY 151: Lecture 4A 4.1 Position, Velocity, and Acceleration Vectors 4.2 Two-Dimensional Motion with Constant Acceleration 4.3 Projectile Motion.
Copyright © Cengage Learning. All rights reserved. Vectors in Two and Three Dimensions.
Chapter 3 Vectors. Vector quantities  Physical quantities that have both numerical and directional properties Mathematical operations of vectors in this.
 Problem Analysis  Coding  Debugging  Testing.
Chapter Projectile Motion 6.1.
Chapter 1 Introduction.
Describing Motion with Equations
Bell Ringer pg.26 Why does a bullet that is dropped and a bullet is shot at the same time horizontally from the same height land at the same time?
How far up does the coin go?
PHYS 1441 – Section 001 Lecture #6
Unit# 9: Computer Program Development
Chapter 3 Vectors.
College Physics Chapter 1 Introduction.
Kinematics Projectile Motion
Chapter 1 Units and Problem Solving
Tutorial 2 The Derivative
PROJECTILE MOTION.
Presentation transcript:

An Introduction to Programming and Algorithms

Course Objectives A basic understanding of engineering problem solving process. A basic understanding of how computer programs work. Ability to use MATLAB environment to solve common engineering mathematics problems.

Engineering Problem Solving Engineering often involves applying a consistent, structured approach to the solving of problems. Problems must be approached methodically, applying an algorithm, or a step-by-step procedure by which one arrives at a solution.

Problem Solving Process 1. Define the problem and gather information 2. Create a mathematical model. 3. Develop a computational method for solving the problem. 4. Implement the computational method. 5. Test and assess the solution.

Problem Definition Recognize and define the problem precisely by exploring it thoroughly (probably the most difficult step) Determine what question is to be answered and what output or results are to be produced. Determine what theoretical and experimental knowledge can be applied. Determine what input information or data is available

Collect and Verify Information Collect all data and information about the problem. Verify the accuracy of this data and information. Determine what information you must find intermediate results or data may need to be found before the required answer or results can be found.

Mathematical Model Determine what fundamental principles are applicable. Draw sketches or block diagrams to better understand the problem. Define necessary variables and assign notation. Reduce the problem as originally stated into one expressed in purely mathematical terms. Apply mathematical expertise to extract the essentials from the underlying physical description of the problem. Simplify the problem only enough to allow the required information and results to be obtained. Identify and justify the assumptions and constraints inherent in this model.

Computational Method Derive a set of equations that allow the calculation of the desired parameters and variables. Develop an algorithm, or step-by-step method of evaluating the equations involved in the solution. Describe the algorithm in mathematical terms and then implement as a computer program. Carefully review the proposed solution, with thought given to alternative approaches.

Implementation of Computational Method Assess the computational power needed, as an acceptable implementation may be hand calculation with a pocket calculator. If a computer program is required, a variety of programming languages, each with different properties, are available. A variety of computers, ranging from the most basic home computers to the fastest parallel supercomputers, are available. The ability to choose the proper combination of programming language and computer, and use them to create and execute a correct and efficient implementation of the method, requires both knowledge and experience.

Test and Assess the Solution A simple version of the problem should be hand checked. The program should be executed on obtained or computed test data for which the answer or solution is either known or which can be obtained by independent means, such as hand or calculator computation. Intermediate values should be compared with expected results and estimated variations. When values deviate from expected results more than was estimated, the source of the deviation should be determined and the program modified as needed. A “reality check” should be performed on the solution to determine if it makes sense. The assumptions made in creating the mathematical model of the problem should be checked against the solution.

Problem Solving Example As an example of the problem solving process, consider the following problem: “A small object is launched into flight from the ground at a speed of 50 miles/hour at 30 degrees above the horizontal over level ground. Determine the time of flight and the distance traveled when the ball returns to the ground.”

Problem Definition Output or results to be produced: Time of flight & Distance travelled Theoretical and experimental knowledge to be applied: Ballistic motion in two dimensions Input information or data: This includes the object initial velocity of 50 miles per hour at an angle 30 degree above horizontal.

Points to Consider Properties of the object and the flight medium could affect the flight trajectory. Gravity9,81 m/s Precision and Accuracy of input data Unit conversions 1 km = 1000 m1hr = 3600 s 360 degrees = 2π radians (To convert degrees to radians, multiply it with pi/180)

Mathematical Model Define the notation: Time: t (s), with t = 0 when the object is launched. Initial velocity magnitude: v = 50 mph. Initial angle: θ = 30 0 Horizontal position of ball: x(t) (ft) Vertical position of ball: y(t) (ft) Acceleration of gravity: g = 32,2 ft/s2 (9.81 m/s2)

Mathematical Model x(t) = vt cos θ y(t) = vt sin θ – (1/2)gt 2

Computational Method Using the model developed above, expressions for the desired results can be obtained. The object will hit the ground when its vertical position is zero: which can be solved to yield two values of time

Computational Method The second of the two solutions indicates that the object will return to the ground at the time The horizontal position (distance of travel) at this time is

Computational Implementation Terminal (start, stop) Input/Output Decision Process FLOW CHARTS

First Program - sum two numbers Algorithm 1. Start 2. Read A & B 3. Add A to B, store in C 4. Output C 5. Stop Start Add A to B, Store in C Output C Stop Input A,B FlowchartPseudocode BEGIN Adder INPUT a INPUT b c = a + b PRINT c END Adder See C&C p. 31

Computational Implementation

Good Programming Habits Use comments liberally, both at the beginning of a script, to describe briefly what it does and any special methods that may have been used, and also throughout the script to introduce different logical sections. Describe each variable briefly in a comment when it is initialized. Separate sections of code with blank lines. Indent multiple line structures to make them stand out as a logical unit. Use spaces in expressions to make them more readable (for example, on either side of operators and equal signs).

Testing and Assessing the Solution Executing the statements above provides the following displayed results: Check these quantities with a calculator

Testing and Assessing the Solution Check the plot