210 likes | 487 Views
Problem Solving: Practice & Approaches. Practice solving a variety of problems Strategies for solving problems More Practice. General Idea of This Lesson. Programming is like learning a language
E N D
Problem Solving: Practice & Approaches Practice solving a variety of problems Strategies for solving problems More Practice
General Idea of This Lesson • Programming is like learning a language • You need to learn the vocabulary (keywords), grammar (syntax), and how to use punctuation (symbols) • Problem solving is like learning to cook • A novice chef has a recipe • An master chef can create their own recipe Both tasks require practice!
Review: Scientific Problem-Solving Method • Problem Statement • Diagram • Theory • Assumptions • Solution Steps • Identify Results & Verify Accuracy • Computerize the solution • Deduce the algorithm from step 5 • Translate the algorithm to lines of code • Verify Results
Example #1: Balancing a fulcrum Two children of known mass sit on a 5.00-m long teeter-totter. Where should the fulcrum be placed so the two children balance? (Note: an object is in static equilibrium when all moments balance.) Using the supplied worksheet, solve the problem work on the first couple of steps: On your own With your neighbors What did you get?
Example #1: Balancing a fulcrum • Reminder: Algorithms are a finite-list of instructions to follow to complete a task Recipes Pre-flight checklist Post-flight checklist
Problem Solving Strategies • The trouble with Step 5: “Solution Steps” There can be many approaches to solving the same problem • Creativity is an important component on how we view and approach problems:
Creativity • Connect the following 9 dots with four continuous lines without lifting your pencil Sometimes you will need to think outside the box
Problem Solving Strategies (Polya, 1945) • Utilize analogies • Flow through a piping system can be modeled with electronics Resistors – Fluid Friction Capacitors – Holdup tanks Batteries – Pumps • Work Auxiliary Problems • Remove some constraints • Generalize the problem Ex: L1= m2* L / (m1 + m2)
Problem Solving Strategies (Polya, 1945) • Decompose & Recombine problems • Break the problem into individual components Calculate Cost of Area • Prove the following equation 2 x 2 x 2 x 2 = 16
Problem Solving Strategies (Polya, 1945) • Work backwards from the solution Ex: Measure exactly 7 oz. of liquid from an infinitely large container using only a 5 oz. container and an 8 oz. container Solution: • Fill 5 oz container and empty into 8oz • Fill 5 oz container again, then pour to top-off 8oz container (2 oz remaining in 5 oz) • Empty 8 oz and fill with the remaining 2oz from 5oz container • Fill 5 oz container and add it to the 8oz container 8 7? 5
Example #2: Fuel tank design A fuel tank is to be constructed that will hold 5 x 105 L. The shape is cylindrical with a hemisphere top and a cylindrical midsection. Costs to construct the cylindrical portion will be $300/m2 of surface area and $400/m2 of surface area of the hemispheres. What is the tank dimension that will result in the lowest dollar cost?
Example #2: Fuel tank design • Problem Statement: Givens Required: CostHemisphere = $300/m2 CostCylinder = $400/m2 VolumeTank = 500,000 L Find: Radius(meter) and height (meter) for minimum cost ($) • Diagram R H
Example #2: Fuel tank design • Theory Volume Cylinder : Volume Hemisphere: Surface Area Cylinder: Surface Area Hemisphere: • Assumptions No dead air space Construction cost independent of size Other costs do not change with tank dimensions Thickness of walls is negligible Bottom flat portion of tank is free. 1 2 3 4
Example #2: Fuel tank design • Solution Steps 1. Substitute equations Solve for H with respect to R 2. Substitute equations • Solve for Cost with • respect to radius
Example #2: Fuel tank design • Various methods to solve can be used to calculate minimum cost • Plot the data • Identify minimum for an array of costs • Numerical Methods (Iterative solutions) • Use mathematical analysis using derivatives (MA241)
Example #2: Fuel tank design • Solution Steps (continued) Solve for H with identified R where R H • H = 3.03m
Example #2: Fuel tank design 5. Another solution possible Take the derivative of the cost function: Does this make sense? • Units? • Overall Dimension? • Can you rerun the analyses with other givens using Step 5? 5m 3m 5VTank = 500,000L
Algorithms Option 1 - Plotting Option 2 - Minimum define cost hemisphere/tank define total volume set range of radius (0-100m) calculate cost for each radius determine minimum of all cost calculate height cylinder Option 3 - Derivatives • define cost hemisphere/tank • define total volume • set range of radius (0-100m) • calculate cost for each radius • plot cost vs. radius • read off graph lower cost • calculate height cylinder • define cost hemisphere/tank • define total volume • solve for radius using derivative • solve for cost • calculate height cylinder
Wrapping Up • Utilize the 7 step process before you begin programming • Be clear about your approach • Think creatively • Use a couple of strategies when understanding a problem • Practice! • Use MATLAB to make your life easier
Try it yourself • What if the fuel tank had two hemispheres? A fuel tank is to be constructed that will hold 5 x 105 L. The shape is cylindrical with a hemisphere top, a hemisphere base and, and a cylindrical midsection. Costs to construct the cylindrical portion will be $250/m2 of surface area and $300/m2 of surface area of the hemispheres. What is the tank dimension that will result in the lowest dollar cost? R H