ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software.

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

CS101: Introduction to Computer programming
Algorithms An algorithm is a finite sequence of instructions, logic, an explicit step-by-step procedure for solving a problem. Specific algorithms sometimes.
Chapter 3 Program Design And Branching Structures.
PROBLEM SOLVING TECHNIQUES
ALGORITHMS AND FLOWCHARTS
Mathematics for Computing Lecture 4: Algorithms and flowcharts Dr Andrew Purkiss-Trew Cancer Research UK
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
ITEC113 Algorithms and Programming Techniques
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 4 Programming and Software EXCEL and MathCAD.
Program Design and Development
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 2 Mathematical Modeling and Engineering Problem Solving.
The Islamic University of Gaza Faculty of Engineering Numerical Analysis ECIV 3306 Introduction.
Chapter 1 Program Design
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 1 Mathematical Modeling.
Chapter 3 Planning Your Solution
Review Algorithm Analysis Problem Solving Space Complexity
ALGORITHMS AND FLOWCHARTS
CIS Computer Programming Logic
Numerical Methods in Scientific Computation Lecture 2 Programming and Software Introduction to error analysis Numerical Methods, Lecture 2 1 Prof. Jinbo.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 2.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
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.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Visual Basic Programming
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Lecture 2 Numerical Methods for Engineering MECN 3500 Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus Dr.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Introduction to Flowcharts
Program Program is a collection of instructions that will perform some task.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
Lecture 3 Computer Programming -1-. The main steps of program development to solve the problem: 1- problem definition : The problem must be defined into.
Program design Program Design Process has 2 phases:
ALGORITHMS AND FLOWCHARTS
Understand Problem Solving Tools to Design Programming Solutions
GC101 Introduction to computers and programs
Unit 3: ALGORITHMS AND FLOWCHARTS
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Algorithm & Programming
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Algorithms and Flowcharts
Introduction To Flowcharting
Introduction to Computer Programming
Programming Fundamentals
Computer Programming.
ALGORITHMS AND FLOWCHARTS
Visual Basic 6 Programming.
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
A programming language
Flowcharts and Pseudo Code
Introduction to Programming
Basic Concepts of Algorithm
Presentation transcript:

ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software

Last Time Mathematical Model Physical Problem Mathematical Model DataTheory Numeric or Graphic Results Implementation

Last Time Mathematical Model A formulation or equation that expresses the essential features of a physical system or process in mathematical terms Dependent Variable =f Independent Variables Forcing Functions Parameters

Mathematical Model Fundamental Laws Conservation of Mass Conservation of Momentum Conservation of Energy

Mathematical Model Change = Increase - Decrease Change  0 : Transient Computation Change = 0 : Steady State Computation Expressed in terms of

Analytic vs Numerical Solution t (s)v (m/s)

Software Packages Users StandardPower Limited to standard software capabilities Write your own macros and/or software

Objectives Computer Implementation of Numerical Methods Introduce Algorithms Discuss Flowcharts Discuss Pseudocodes Programming Tools and Styles

Computer Implementation Algorithm Flowchart Pseudocode Computer Program

Algorithms & Flowcharts Algorithm The step by step procedure that describes the implementation of a solution strategy. Flowchart The visual representation of an algorithm.

Flowchart Symbols Used in Flowcharts

Pseudocode and Computer Code Computer Code Set of Instructions in a computer language that direct the computer to perform a certain task. Pseudocode Set of code-like instructions that express the flowchart in a narrative form

VISUAL C++

FORTRAN

Visual Basic

MathCAD

Building Software… Instructions in TEXT form

Building Software… Compiled Form….

Building Software… Compiled Form….

Building Software… Linked Form…..exe

Programming Topics Simple Information Specification –Constants, variables, type declarations Advanced Information Representation –Arrays, data structures, records Mathematical Formulas –Operators, priority rules, intrinsic functions Input/Output Logical Representation –Sequence, selection and repetition Modular Programming –Functions and Subroutines

Programming Topics Simple Information Specification –Constants, variables, type declarations Advanced Information Representation –Arrays, data structures, records Mathematical Formulas –Operators, priority rules, intrinsic functions Input/Output Logical Representation –Sequence, selection and repetition Modular Programming –Functions and Subroutines

Simple Information Specifications Constants: Value does not change e.g. acceleration of gravity g_SI=9.81 e.g.  pi=

Simple Information Specifications Variables: Value depends on the problem –User Input Assign descriptive names, e.g. mass instead of m

Simple Information Specifications Type Declaration real mass8 decimal accuracy int istepinteger double g_SI16 decimal accuracy BOOL trivialTRUE/FALSE e.t.c.

Programming Topics Simple Information Specification –Constants, variables, type declarations Advanced Information Representation –Arrays, data structures, records Mathematical Formulas –Operators, priority rules, intrinsic functions Input/Output Logical Representation –Sequence, selection and repetition Modular Programming –Functions and Subroutines

Advanced Information Representation Arrays –N-dimensional matrices of same data type real v(10)velocity at 10 time steps int cell(100,100)100x100 rectangular matrix e.t.c.

Advanced Information Representation Structures and Records –Collection of data types struct STUDENT { charName real GPA int Age BOOLInState }

Programming Topics Simple Information Specification –Constants, variables, type declarations Advanced Information Representation –Arrays, data structures, records Mathematical Formulas –Operators, priority rules, intrinsic functions Input/Output Logical Representation –Sequence, selection and repetition Modular Programming –Functions and Subroutines

Mathematical Formulas Operators, priority rules, intrinsic functions

Programming Topics Simple Information Specification –Constants, variables, type declarations Advanced Information Representation –Arrays, data structures, records Mathematical Formulas –Operators, priority rules, intrinsic functions Input/Output Logical Representation –Sequence, selection and repetition Modular Programming –Functions and Subroutines

Logical Representation Sequence Computer code is to be implemented one instruction at a time Analytic Solution Enter g,m,c Enter time t Evaluate v Print t,v

Logical Representation Selection Computer code flow is split into branches based on a logical decision. Enter g,m,c Check if m=0 Print Error Message OK to continue

Logical Representation Repetition Implement instructions repeatedly

Programming Topics Simple Information Specification –Constants, variables, type declarations Advanced Information Representation –Arrays, data structures, records Mathematical Formulas –Operators, priority rules, intrinsic functions Input/Output Logical Representation –Sequence, selection and repetition Modular Programming –Functions and Subroutines

Modular Programming Module is a self contained and independent code segment Modules are designed to perform a specific, well designed task Functions return a single result Subroutines return several results

Example Consider Quadratic Equation With closed form solution

Example If a,b,c are given Compute x 1 and x 2 What Do I Need?

Example Ask user to input a,b,c Check if a=0 –Linear equation, this solution does not apply Check if a=0 and b=0 –Trivial Solution Check if b 2 -4ac=0 –Double Real Root

Example Check if b 2 -4ac>0 –Two Real Roots Check if b 2 -4ac<0 –Imaginary Roots

Example START a=0 Loop Input a, b, c Print Solution 1 FALSE 2 TRUE Solve Again TRUE END FALSE

Example 1 d Complex Roots d<0d>0 d=0

Example 2 b=0 Trivial Solution TRUEFALSE

DO INPUT a, b, c d = b**2 – 4*a*c IF a = 0 THEN IF b=0 THEN TRIVIAL SOLUTION ELSE x1 = -c/b ENDIF ELSE IF d<0 THEN COMPLEX ROOTS ELSE IF d = 0 THEN x1=x2=-b/2a ELSE x1 = (-b+SQRT(d))/(2*a) x2 = (-b-SQRT(d))/(2*a) ENDIF PRINT Continue? INPUT Control IF ( CONTROL == FALSE ) EXIT ENDDO PSEUDOCODE START a=0 Loop Input a, b, c Print Solution 1 FALSE 2 TRUE Solve Again TRUE END FALSE

Additional Homework Problem 2.8 Do not write a program. Draw the flowchart and pseudocode