Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Similar presentations


Presentation on theme: "Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display."— Presentation transcript:

1 Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

2 Computing Proficiency for Engineers Software Helps Engineers Do Their Jobs – Get Information: Web of Science, Google – Present information and Proposals: PowerPoint – Design: Discipline-specific tools, General Computational Tools – Analyze: Computational Tools, Discipline-specific tools Matlab, Excel, Mathematica, MathCad, Finite Element – Test and Implement: Data acquisition: LabView, Basic Stamp, etc. Statistics: SPSS, SAS, MiniTab, S+, R, etc. – Report: Word, Adobe Design Suite, Framemaker, LaTeX, emacs Engineering Computation: An Introduction Using MATLAB and Excel

3 Computational Tools Used for “everyday” tasks of engineering: – Programming for repetitive calculations – Data analysis – Plotting Many choices: – Programming languages such as C++, Fortran, BASIC – Mathematical computational tools such as MATLAB, Mathematica, Mathcad, Maple – Spreadsheets, such as Microsoft Excel Engineering Computation: An Introduction Using MATLAB and Excel

4 Computational Tools MATLAB – Product of MathWorks, Inc. – Widely used by engineers in academia and in industry – Combines a calculator-type interactive mode and powerful programming tools Excel – Spreadsheet application of Microsoft Office – Originally designed for business use, but now contains many commands and features that are useful for engineering analysis Engineering Computation: An Introduction Using MATLAB and Excel

5 Analytic and Algorithmic Solutions Analytic: Exact solution, based on the application of mathematics Algorithmic: Approximate solution, based on the application of a computational procedure (the algorithm) Engineering Computation: An Introduction Using MATLAB and Excel

6 Example Consider this problem of projectile motion: A ball is fired with an initial speed of 10 m/s, at an angle of 35 degrees relative to the ground. We want to find the maximum height, the location at which the ball hits the ground, and the total flight time. Engineering Computation: An Introduction Using MATLAB and Excel

7 Two ways to find the answers Analytic Solution – Solve calculus problem for motion as a function of time – Analyze the solution to find the point of maximum height – Analyze the solution to find the time the flight ends Algorithmic Solution – Solve calculus problem for motion as a function of time – Evaluate the solution at many time instances – Test each function evaluation for meeting prescribed criteria Engineering Computation: An Introduction Using MATLAB and Excel

8 The Mathematical Model In physics class, you will learn how formulate the mathematical model – the equations describing the physical behavior Start by examining the forces acting on the ball: Engineering Computation: An Introduction Using MATLAB and Excel Weight

9 Mathematical Model (cont.) In the y (vertical) direction, the total force is equal to –W (the weight, acting downward) The weight is equal to the mass times the acceleration (F = ma) Since the weight is equal to mass times g (gravitational acceleration), the vertical acceleration a y = -g Engineering Computation: An Introduction Using MATLAB and Excel

10 Mathematical Model (cont.) Once we know the vertical acceleration, we integrate with respect to time to obtain the vertical velocity: The constant C is a boundary condition (or initial condition). If we evaluate the velocity at time t = 0, we see that C must equal the initial upward velocity Engineering Computation: An Introduction Using MATLAB and Excel

11 Mathematical Model (cont.) Initial velocities: Engineering Computation: An Introduction Using MATLAB and Excel

12 Mathematical Model (cont.) So the vertical velocity is: Integrating this expression with respect to time gives us the vertical position (height): Evaluating at time = 0, since the height = 0, the constant C = 0: Engineering Computation: An Introduction Using MATLAB and Excel

13 Mathematical Model (cont.) Similarly, in the horizontal direction, there are no forces acting on the ball, so Integrating with respect to time gives us the horizontal velocity: When t = 0, we see that C is equal to the initial horizontal velocity Engineering Computation: An Introduction Using MATLAB and Excel

14 Mathematical Model (cont.) Integrating again, we find that the horizontal position x is When t = 0, x = 0, since we have defined the origin of our coordinate system at the cannon. Therefore, Engineering Computation: An Introduction Using MATLAB and Excel

15 Mathematical Model (cont.) So we now have equations for the height and the horizontal distance as functions of time: Engineering Computation: An Introduction Using MATLAB and Excel

16 Assumptions Before proceeding to the solution of the problem, it is important to recognize the assumptions that have been made in the formulation of the mathematical model: 1.There is no air resistance (the weight is the only force considered) 2.The ground if flat and level (the height is measured relative to the initial position) 3.The launch point is even with the ground (the height of the cannon is neglected) Engineering Computation: An Introduction Using MATLAB and Excel

17 Analytic Solution This solution requires calculus (as did the formulation of the mathematical model) To find an extreme value of the height, we differentiate the expression for height with respect to time: Of course this rate of change of height is the vertical velocity, and is equal to zero when an extreme value is reached Engineering Computation: An Introduction Using MATLAB and Excel

18 Analytic Solution (cont.) Setting the rate of change of height equal to zero, we get the value of time for which the height is maximized: Substituting the values of the constants, Engineering Computation: An Introduction Using MATLAB and Excel

19 Analytic Solution (cont.) To find the maximum height, we substitute the time t = 0.585 seconds into the equation for height: So h max = 1.68 meters Engineering Computation: An Introduction Using MATLAB and Excel

20 Analytic Solution (cont.) To find the total time of the flight, set the height equal to zero (since the height will be zero when the ball lands): There are two solutions to this equation: t = 0 (the starting point) and t = 1.17 seconds (the landing point) Engineering Computation: An Introduction Using MATLAB and Excel

21 Analytic Solution (cont.) To find the location where the ball hits the ground, we substitute the time t = 1.17 seconds into the equation for horizontal position x: So x max = 9.58 meters Engineering Computation: An Introduction Using MATLAB and Excel

22 Algorithmic Solution For the algorithmic solution, we will numerically evaluate the equations at different values of time until we find the approximate answer Let’s consider the maximum height, using the equation Engineering Computation: An Introduction Using MATLAB and Excel

23 Algorithmic Solution (cont.) Here is our solution algorithm for finding the maximum height, written in pseudocode: Engineering Computation: An Introduction Using MATLAB and Excel

24 Algorithmic Solution (cont.) How do we determine what value of time interval to use? We make an initial guess, realizing that we may need to repeat the analysis with a different value. Smaller intervals = better accuracy but more calculation steps, larger intervals = less accuracy but fewer steps. Solution with time intervals of 0.1 seconds: Engineering Computation: An Introduction Using MATLAB and Excel

25 Algorithmic Solution (cont.) Here is the algorithm for finding the total flight time and distance travelled: Engineering Computation: An Introduction Using MATLAB and Excel

26 Algorithmic Solution (cont.) Solution with time intervals of 0.1 seconds: Engineering Computation: An Introduction Using MATLAB and Excel

27 Algorithmic Solution (cont.) Based on the solution for total flight time, calculate the total distance travelled from the equation: Solution: Engineering Computation: An Introduction Using MATLAB and Excel

28 Algorithmic Solution (cont.) Results with different values of time intervals: Compare to exact solution: Engineering Computation: An Introduction Using MATLAB and Excel Time Interval, seconds Peak Height, meters Distance Travelled, meters Total Flight Time, seconds Number of Loops Calculated 0.501.641610.23941.25003 0.251.64169.21551.12505 0.101.67579.42021.150012 0.051.67579.62501.175024 0.011.67679.54311.1650117 0.0011.67689.58001.16951170 0.00011.67689.57881.169311694 1.67689.57891.1694

29 Comparison of Solutions Note that the algorithmic solution converges to the exact solution as the time interval is decreased How many intervals should be used? Depends on how accurate the solution needs to be – we will discuss this further when we address accuracy and precision Engineering Computation: An Introduction Using MATLAB and Excel

30 Why Use an Algorithmic Solution? If we can find an exact solution, why use an algorithm? There are many problems faced by engineers in which an exact solution does not exist, or may be very difficult to obtain In other cases, an algorithmic solution provides a check to ensure that the exact solution is correct Engineering Computation: An Introduction Using MATLAB and Excel

31 A Note About the Analytic Solution Remember that what we call the “exact” analytic solution is the exact solution of the mathematical model – not of the physical problem In the case of the cannon ball, recall that we made several assumptions, such as neglecting air resistance The actual flight of the cannon ball may be very close to or very different from the results of the mathematical model, depending on the validity of the assumptions Engineering Computation: An Introduction Using MATLAB and Excel

32 In-Class Exercise Using only the equation for distance Develop an algorithm for finding the launch angle θ that maximizes the distance traveled, given a constant value of initial velocity v Engineering Computation: An Introduction Using MATLAB and Excel

33 Solution In the previous example, there was only one variable: time. For this exercise, there are two variables: time and angle We can use our previously created algorithm for finding the distance traveled: Engineering Computation: An Introduction Using MATLAB and Excel

34 Solution (cont): Define the limits of possible angles: 0 deg < θ < 90 deg Step 1: Set the angle theta, the max distance x_max, and the angle associated to the maximum distance theta_opt equal to zero Step 2: Set the angle theta equal to theta plus a chosen angle increment t_inc (for example, 5 degrees) Step 3: For a chosen initial velocity and time increment, calculate the distance traveled x using the algorithm previously developed Step 4: If x > x_max, set x_max equal to x and theta_opt equal to theta Step 5: Repeat steps 2-4 until theta is greater than or equal to 90 degrees Step 6: Report the value of theta_opt Engineering Computation: An Introduction Using MATLAB and Excel

35 Notes About This Exercise Using a spreadsheet to solve this problem is tedious: requires inputting new data repeatedly A programming language such as MATLAB allows the loops to be automated Engineering Computation: An Introduction Using MATLAB and Excel

36 Solution 45 degrees is the launch angle that results in the greatest distance travelled Engineering Computation: An Introduction Using MATLAB and Excel


Download ppt "Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display."

Similar presentations


Ads by Google