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.

Slides:



Advertisements
Similar presentations
Finding Complex Roots of Quadratics
Advertisements

1.5 Quadratic Equations Start p 145 graph and model for #131 & discuss.
EXAMPLE 4 Use the discriminant Find the discriminant of the quadratic equation and give the number and type of solutions of the equation. a. x 2 – 8x +
Solving Quadratic Equations Algebraically Lesson 2.2.
Objectives: 1. Solve equations by: A. Factoring B. Square Root of Both Sides C. Completing the Square D. Quadratic Formula 2. Solve equations in quadratic.
Complex Number A number consisting of a real and imaginary part. Usually written in the following form (where a and b are real numbers): Example: Solve.
EXAMPLE 4 Choose a solution method Tell what method you would use to solve the quadratic equation. Explain your choice(s). a. 10x 2 – 7 = 0 SOLUTION a.
4.8 Quadratic Formula and Discriminant
The Quadratic Formula..
Solving Quadratic Equations Section 1.3
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 1 Equations and Inequalities Copyright © 2013, 2009, 2005 Pearson Education, Inc.
Copyright © Cengage Learning. All rights reserved.
Objective Solving Quadratic Equations by the Quadratic Formula.
4.8: Quadratic Formula HW: worksheet
Sec 5.6 Quadratic Formula & Discriminant Quadratic Formula (Yes, it’s the one with the song!) If ax 2 + bx + c = 0 and a ≠ 0, then the solutions (roots)
Introduction to Computers and Programming History of computers What is a computer system? What is a software? What is programming? Different languages.
Warm up – Solve by Taking Roots. Solving by the Quadratic Formula.
The Quadratic Formula Solving quadratic equations.
Section 10.5 – Page 506 Objectives Use the quadratic formula to find solutions to quadratic equations. Use the quadratic formula to find the zeros of a.
Solving quadratic equations – AII.4b
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics.
Developing a Solution How to create the computer-based solution for a real-world problem. 1.
Developing a Solution How to create the computer-based solution for a real-world problem. 1.
Developing a Solution Getting past the panic of staring at a “blank sheet” of paper when solving a problem 1.
5.6 Quadratic Equations and Complex Numbers
Solving Quadratic Equations Using Completing the Square and the Quadratic Formula.
Goals: To solve quadratic equations by using the Quadratic Formula.
Developing a Solution Getting past the panic of staring at a “blank sheet” of paper when solving a problem 1.
5.6 Quadratic Formula & Discriminant
Do Now : Evaluate when x = 6, y = -2 and z = The Quadratic Formula and the Discriminant Objectives Students will be able to: 1)Solve quadratic.
4.8 Do Now: practice of 4.7 The area of a rectangle is 50. If the width is x and the length is x Solve for x by completing the square.
The Quadratic Formula & Discriminant Essential question – How do you solve a quadratic equation using the Quadratic Formula?
What you will learn How to solve a quadratic equation using the quadratic formula How to classify the solutions of a quadratic equation based on the.
Lecture 5 1.What is a variable 2.What types of information are stored in a variable 3.Getting user input from the keyboard 1.
Pre-Calculus Lesson 5: Solving Quadratic Equations Factoring, quadratic formula, and discriminant.
Quadratic Formula You can use this formula to find the solutions(roots) to a quadratic equation. This formula can be broken up into 2 parts: b 2 – 4ac.
The Quadratic Formula Students will be able to solve quadratic equations by using the quadratic formula.
Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:
Getting Started The objective is to be able to solve any quadratic equation by using the quadratic formula. Quadratic Equation - An equation in x that.
Notes Over 5.6 Quadratic Formula
Chapter 4: Polynomial and Rational Functions. 4-2 Quadratic Equations For a quadratic equation in the form ax 2 + bx + c = 0 The quadratic Formula is.
Solving Quadratic Equations by Using the Quadratic Formula (9-5) Objective: Solve quadratic equations by using the Quadratic Formula. Use the discriminant.
Warm Up  1.) Write 15x 2 + 6x = 14x in standard form. (ax 2 + bx + c = 0)  2.) Evaluate b 2 – 4ac when a = 3, b = -6, and c = 5.
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.
SOLVE QUADRATIC EQUATIONS BY USING THE QUADRATIC FORMULA. USE THE DISCRIMINANT TO DETERMINE THE NUMBER AND TYPE OF ROOTS OF A QUADRATIC EQUATION. 5.6 The.
Solving Quadratic Equations by the Quadratic Formula.
Section 2.5 – Quadratic Equations
Do Now Use the standard form of a quadratic equation to find the a, b and c of each equation. ax2 + bx + c = 0 x2 – 6x + 10 = 0 2x2 + 3x + 4 = 0 x2 –
4.6 Quadratic formula.
The Quadratic Formula & Discriminant
Warm up – Solve by Taking Roots
Quadratic Equations P.7.
Solving quadratics methods
Do Now – Take out your homework. Take You have 5 minutes.
Algorithms and Flowcharts
Copyright © 2017, 2013, 2009 Pearson Education, Inc.
4.6 Quadratic formula.
Worksheet Key 9 11/14/2018 8:58 PM Quadratic Formula.
3.7: Solving Quadratic Equations by the Quadratic Formula
4.8 The Quadratic Formula and the Discriminant
Unit 7 Day 4 the Quadratic Formula.
Questions over HW?.
Warm up – Solve by Completing the Square
Review: Simplify.
Solving Quadratic Equations by the Quadratic Formula
Warm Up #4 1. Write 15x2 + 6x = 14x2 – 12 in standard form. ANSWER
The Discriminant.
Using the Quadratic Formula to Solve Quadratic Equations
  Warm Up:.
The Discriminant.
Presentation transcript:

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 a Solution 1

1. Understanding the problem However the problem may seem, it is crucial to fully understand the problem: Brainstorm! For example: Solve the area of a triangle What way would you go about doing this: On Paper? Preparing it for the machine? 2

2. Brainstorm What do you know about the problem? How do you want to solve it? height base side 1 side 2 angle Area = ½ * base * height Area = ½ * side2 * side 1 * sin(angle) 3

3. Drawing an I/O diagram Remember the Von Neumann architecture? The I/O diagram determines which input and output device the software will use, as well as decide which inputs values and output values it will use. The I/O diagram is a first step to organizing the brainstorming. 4

General I/O diagram INPUT SIDE OUTPUT SIDE 5 ? ? ? ? ? ? ? ?

Possible I/O diagram for the area of a triangle (option1) AREA OF TRIANGLE Side 1 and 2 Angle SCREEN Arrows represent the GIVENS (=INPUTS) Arrows represent the RESULTS (=OUTPUTS) External interface – What HARDWARE is used for each area 6 KEYBOARD

Possible I/O diagram for the area of a triangle (option2) AREA OF TRIANGLE Side 1 and 2 Angle PRINTER Arrows represent the GIVENS (=INPUTS) Arrows represent the RESULTS (=OUTPUTS) External interface – What HARDWARE is used for each area 7 DATA BASE 7

Possible I/O diagram for the area of a triangle (option3) AREA OF TRIANGLE base height SCREEN Arrows represent the GIVENS (=INPUTS) Arrows represent the RESULTS (=OUTPUTS) External interface – What HARDWARE is used for each area 8 KEYBOARD 8

Some Other More Complex Examples (and yet, the I/O is not so complex) 9 ATM MACHINE money Money Slot pin Deposit/with- draw/transfer… Touch Screen/ pin pad Account number Card receipt Receipt Slot Money Slot money 9

SIMCT (or: Small iPods Make Copying Tough) S – State the problem I – Inputs and Outputs (identify them) M – (Be able to) Manually solve the problem C – Computerize the solution Layout the algorithm Provide the code that implements the algorithm T – test, Test, TEST!! 10 Note: I and M are usually mixed up. You obvioulsy need to brainstorm, solve the problem, find obstacles to fix, resolve it again to eventually zoom in on the correct inputs/outputs..

Example Problem We want to have a computer program find the roots of quadratic equations: ax 2 + bx + c = 0 11

Example Problem (cont.) State the problem: “I want a computer program that will find the roots of a quadratic equation” Any quadratic equation? What if a=0? What if the roots are imaginary? 12

Example Problem (cont.) Restate the problem: “I want a computer program that will find the REAL roots of a quadratic equation for all REAL coefficients a, b, and c such that a≠0.” This shows a much more thorough consideration of the problem 13

Example Problem (cont.) Step 2: Inputs and Outputs What are the inputs for this problem? In other words, what information is needed FROM OUTSIDE THE PROGRAM for the desired program to solve the problem? 14

Example Problem (cont.) Inputs, continued… The only information needed from outside the program are the values of the coefficients. 15

Example Problem (cont.) Outputs: What are we expecting as output from this program? The roots, of course. But what about error messages – when the user puts in bad information? What about an “imaginary roots found” message? 16

Example Problem (cont.) Outputs, continued: - The roots, if real - Message if roots are imaginary - Error if the user inputs bad values 17

Example Problem (cont.) (Be able to) Manually Solve the Problem Not always practical to actually solve the problem. But you must be able to solve the problem manually, assuming you had the time and resources necessary. Otherwise, how will you tell the computer how to do it? 18

Example Problem (cont.) Manually solve the problem, continued… For this problem, you might manually solve the quadratic equation for various inputs. Pretend you are the program you will be writing. What should YOU do if the user provides you with good data; bad data; data that gives real roots; data that gives imaginary roots. 19

Example Problem (cont.) Computerize the solution Algorithm: Describe the steps you took when you manually solved the problem. This is more difficult than it seems. Humans perform actions subconsciously – we’re not even aware we are doing them! 20

Example Problem (cont.) Algorithm, continued… Layout the algorithm in “skeleton” form: % Collect the inputs from the user % Apply the inputs to the quadratic formula % Display the results 21

Example Problem (cont.) Now, “flesh it out” % Collect the inputs from the user % Print error message if bad inputs % Apply the inputs to the quadratic formula % Compute the discriminant (b 2 -4ac) % If discriminant < 0 % display ‘Imaginary roots’ % Otherwise % compute real roots % Display the results 22

Example Problem (cont.) Computerize, step 2: Code For each step of the algorithm, write code (in this class, MATLAB code) that will perform the actions you have specified. Avoid proceeding with the next step until you feel certain the step has been accomplished. (Actual coding steps will be learned this semester) 23

Example Problem (cont.) test, Test, TEST!! It is provably impossible to write a computer program to test another arbitrary computer program for correctness. So we usually resort to manual testing. For most programs, it is not possible to test a program too thoroughly because it is not possible to test all inputs. Choose your inputs to maximize confidence that the solution you have written will work correctly. 24

Example Problem (cont.) For our quadratic solver, we would want to choose inputs such as: a<0, b<0, c<0 a<0, b<0, c=0 a 0 a<0, b=0, c<0 a<0, b=0, c=0 a 0 a 0, c<0 a 0, c=0 a 0, c>0 a=0, b<0, c<0 a=0, b<0, c=0 a=0, b 0 a=0, b=0, c<0 a=0, b=0, c=0 a=0, b=0, c>0 a=0, b>0, c<0 a=0, b>0, c=0 a=0, b>0, c>0 a>0, b<0, c<0 a>0, b<0, c=0 a>0, b 0 a>0, b=0, c<0 a>0, b=0, c=0 a>0, b=0, c>0 a>0, b>0, c<0 a>0, b>0, c=0 a>0, b>0, c>0 25

Example Problem (cont.) Of course, with human ingenuity, we can design the program to avoid some of these: % If there was no error condition (such as a=0) % then compute the roots % Otherwise, print the error message only With this sort of technique, we can avoid having to test nearly 1/3 of the possibilities! 26

Example Problem (cont.) % Collect the inputs from the user % If no error condition % Compute the discriminant (b 2 -4ac) % If discriminant < 0 % display ‘Imaginary roots’ % Otherwise % compute real roots % Display the results % Otherwise % Print error message 27

% Collect the inputs from the user a = input(‘Enter coefficient a: ’); b = input(‘Enter coefficient b: ’); c = input(‘Enter coefficient c: ’); % If no error condition if a~=0 %means 1 not equal to zero, could have done (a 0) % Compute the discriminant (b 2 -4ac) discriminant = b^2-4*a*c; % If discriminant < 0 if discriminant<0 % display ‘Imaginary roots’ disp(‘Imaginary Roots’) % Otherwise else % compute real roots x1 = (-b + sqrt(discriminant)) / (2*a); x2 = (-b - sqrt(discriminant)) / (2*a); % Display the results fprintf(‘x1 = %.2f and x2 = %.2f\n’,x1,x2) end % Otherwise else % Print error message disp(‘error: a invalid’) end 28