Electrical and Computer Engineering Department SUNY – New Paltz

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

Lecture 4 Structure plan Program design process Program design process Basic elements of code: Basic elements of code: –Input (assignment of variables)
Exercise (1).
Mathematics for Computing Lecture 4: Algorithms and flowcharts Dr Andrew Purkiss-Trew Cancer Research UK
CMPT 120 Introduction to Computer Science and Programming I Chris Schmidt.
solution If a quadratic equation is in the form ax 2 + c = 0, no bx term, then it is easier to solve the equation by finding the square roots. Solve.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
CSE115/ENGR160 Discrete Mathematics 02/24/11 Ming-Hsuan Yang UC Merced 1.
The Quadratic Formula by Zach Barr Simulation Online.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 4 Programming and Software EXCEL and MathCAD.
ENGG 1801 Engineering Computing MATLAB Lecture 2: Background for Week 4 Tutorial Simple Programming in MATLAB.
Branches and Loops Selim Aksoy Bilkent University Department of Computer Engineering
Review Algorithm Analysis Problem Solving Space Complexity
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
The Fundamentals: Algorithms, the Integers & Matrices.
The Quadratic Formula..
SUNY-New Paltz Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz “Lecture 3”
Goals: To solve quadratic equations by using the Quadratic Formula.
Module :MA0001NP Foundation Mathematics Lecture Week 9.
The Quadratic Formula. What does the Quadratic Formula Do ? The Quadratic formula allows you to find the roots of a quadratic equation (if they exist)
Software Life Cycle What Requirements Gathering, Problem definition
1. Understanding the Problem 2. Brainstorming 3. Drawing an I/O (Input/Output) diagram 4. 5-step Process (or: Small iPods Make Copying Tough) Developing.
Factor: Factor: 1. s 2 r 2 – 4s 4 1. s 2 r 2 – 4s b b 3 c + 18b 2 c b b 3 c + 18b 2 c 2 3. xy + 3x – 2y xy + 3x – 2y -
Learning Target: Students will solve quadratic equations using the quadratic formula in mathematical and real-world situations and use the determinant.
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
The Quadratic Formula Students will be able to solve quadratic equations by using the quadratic formula.
Solving Quadratic Equations Quadratic Equations: Think of other examples?
Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.
Problem, Problem Solving, Algorithm & Flow Charts –Part 1 Presented By Manesh T Course:101 CS 101CS Manesh T1.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 4 Monday 06 Oct 2014 EGR 115 Introduction to Computing for Engineers.
SAT Problem of the Day. 5.6 Quadratic Equations and Complex Numbers 5.6 Quadratic Equations and Complex Numbers Objectives: Classify and find all roots.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
PreCalculus Section 1.6 Solve quadratic equations by: a. Factoring b. Completing the square c. Quadratic formula d. Programmed calculator Any equation.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Lesson 6.5: The Quadratic Formula and the Discriminant, pg. 313 Goals: To solve quadratic equations by using the Quadratic Formula. To use the discriminant.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
PreCalculus Section 1. 6 Solve quadratic equations by: a. Factoring b
Introduction to Computer Science and Programming I Chris Schmidt
Program design Program Design Process has 2 phases:
The Quadratic Formula..
4.6 Quadratic formula.
ALGORITHMS AND FLOWCHARTS
Aim: What are the properties of a quadratic equation?
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
The Quadratic Formula..
Algorithm & Programming
ECE 1304 Introduction to Electrical and Computer Engineering
Solving quadratics methods
Quadratic Formula Solving for X Solving for quadratic equations.
Do Now – Take out your homework. Take You have 5 minutes.
GC211Data Structure Lecture2 Sara Alhajjam.
ALGORITHMS AND FLOWCHARTS
3.1 Algorithms (and real programming examples).
ENGG 1801 Engineering Computing
Algorithm Algorithm is a step-by-step procedure or formula or set of instruction for solving a problem Its written in English language or natural language.
Introduction to Computer Programming
4.6 Quadratic formula.
Lecture 2: Introduction to Algorithms
Introduction to Algorithms
Introduction to Algorithms and Programming
Lecture 4 Structure plan
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Basic Concepts of Algorithm
The Quadratic Formula..
The Quadratic Formula..
Electrical and Computer Engineering Department SUNY – New Paltz
Electrical and Computer Engineering Department SUNY – New Paltz
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

Electrical and Computer Engineering Department SUNY – New Paltz Computer Simulation “Lecture 4” Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz

Developing algorithms ·       structure plan (pseudo- code) ·        systematic procedure or algorithm SUNY-New Paltz

What is an Algorithm? In mathematics and computer science, an algorithm is an unambiguous specification of how to solve a class of problems. Starting from an initial state and initial input, the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" SUNY-New Paltz

Solving Quadratic Equation Structure plans Solving Quadratic Equation ax2 + bx + c = 0 Input data Second Order(a=0)? If not x=-c/b Is (b2-4ca)<0 If yes then complex roots Otherwise x1,2 = (± b + √b2 − 4ac)/(2a) SUNY-New Paltz

Pseudo Code Input data Second Order(a=0)? If not x=-c/b Start Input data (a, b, c) If a = 0 then If b = 0 then If c = 0 then Display ‘Solution indeterminate’ else Display ‘There is no solution’ x = −c/b Display x (only one root: equation is linear) else if b2 < 4ac then Display ‘Complex roots’ else if b2 = 4ac then x = −b/(2a) Display x (equal roots) x1 = (−b + √b2 − 4ac)/(2a) x2 = (−b − √b2 − 4ac)/(2a) Display x1, x2 Stop. Input data Second Order(a=0)? If not x=-c/b Is (b2-4ca)<0 If yes then complex roots Otherwise x1,2 = (± b + √b2 − 4ac)/(2a) SUNY-New Paltz

MATLAB CODE(2) SUNY-New Paltz a = input('Enter a :'); Start Input data (a, b, c) If a = 0 then If b = 0 then If c = 0 then Display ‘Solution indeterminate’ else Display ‘There is no solution’ x = −c/b Display x (only one root: equation is linear) else if b2 < 4ac then Display ‘Complex roots’ else if b2 = 4ac then x = −b/(2a) Display x (equal roots) x1 = (−b + √b2 − 4ac)/(2a) x2 = (−b − √b2 − 4ac)/(2a) Display x1, x2 Stop. a = input('Enter a :'); b = input('Enter b :'); c = input('Enter c :'); if a == 0 if b == 0 if c == 0 display( 'Solution indeterminate!'); else display('There is no solution'); end x==-c/b; display(['only one root: equation is linear, x=', num2str(x)]); else if b*b < 4*a*c display('Complex roots') else if b*b == 4*a*c x = -b/(2*a) display(['equal roots, x1=x2=',num2str(x)]); x1 = (-b + sqrt(b*b - 4*a*c))/(2*a); x2 = (-b - sqrt(b*b - 4*a*c))/(2*a); display (['distinct roots x1=', num2str(x1),' x2=', num2str(x2)]); SUNY-New Paltz

SOLUTION INDETERMINATE! Flow Chart N Y START a = 0 ? b = 0 x=-c/b b2 – 4ac>0? x1,2 =(±b+sqrt(b2 – 4ac))/2a c = 0 Input coefficients Y Y SOLUTION INDETERMINATE! COMPLEX SOLUTIONS! THERE IS NO SOLUTION! SUNY-New Paltz

SOLUTION INDETERMINATE! MATLAB CODE(3) N Y START INPUT COEFFICIENTS a = 0 ? b = 0 THERE IS NO SOLUTION! x=-c/b b2 – 4ac>0 x1,2 =(±b+sqrt(b2 – 4ac))/2a COMPLEX SOLUTIONS! c = 0 SOLUTION INDETERMINATE! a = input('Enter a :'); b = input('Enter b :'); c = input('Enter c :'); if a == 0 if b == 0 if c == 0 display( 'Solution indeterminate!'); else display('There is no solution'); end x==-c/b; display(['only one root: equation is linear, x=', num2str(x)]); else if b*b < 4*a*c display('Complex roots') else if b*b == 4*a*c x = -b/(2*a) display(['equal roots, x1=x2=',num2str(x)]); x1 = (-b + sqrt(b*b - 4*a*c))/(2*a); x2 = (-b - sqrt(b*b - 4*a*c))/(2*a); display (['distinct roots x1=', num2str(x1),' x2=', num2str(x2)]); N Y Y SUNY-New Paltz

Components of Flowchart SUNY-New Paltz

Example of a Flowchart SUNY-New Paltz

Example of a Flowchart SUNY-New Paltz

Exercise Write a flow chart that implements the following algorithm: A single die is rolled If it is even, print “Even Roll!” If it is odd, print “Odd Roll” Modify the process to roll indefinitely! SUNY-New Paltz

Exercise   SUNY-New Paltz

Exercise Write a flow chart that implements the following algorithm: Set vector V=[ 2, 5, -1, 6, 0] Initialize variable maximum myMax = 2 Search through the vector and compare all the elements of the vector to find the maximum of the vector. SUNY-New Paltz