Nature, Motivation and Teaching Methodology
for Engineering Problem Solving and
Computer Programming
K. Ming Leung
Department of Computer Science and Engineering Polytechnic School of Engineering, NYU
2014.05.07
Why Use Matlab?
Five years ago, CS1133 replaced CS1114 as the first computer course for engineering students.
It assumes the students have no prior programming experience.
It uses Matlab, a computer programming language that is easier to use – to write and debug programs.
It is especially good for testing ideas and for rapid prototyping.
Testing New Ideas
Consider this problem: for the floating-point numbers between 0 and 1, what is the proportion of them that do not give 1 when they are multiplied by their own reciprocal?
I derived a result for a tight upper bound: (1 ln(2))/2. This result can be tested easily in Matlab within seconds.
Why Use Matlab? (cont.)
Producing graphs and other visualizations are handy for interpretation and analysis of results in engineering applications.
From quick and simple, to sophisticated publication-quality graphics can be produced.
For example,
how does the functionf(x) = cos(x) exp( 0.3x)) look like from 0 to 15? Matlab has thousands of built-in rather general functions, as well as toolboxes for numerous specialized scientific and engineering applications. Thus Matlab is useful also for upper-level courses in many disciplines (such as solving di↵erential equations in Mechanical Engineering, processing signal and images in Electrical Engineering).
The Sunflower Head
The arrangement of seeds (florets) on the head of a sunflower can be
described mathematically in polar coordinates: 1
rk =
p
k, ✓k =k , for k = 1,2, . . . ,n,
with the divergent angle =⇡(3 p5) (⇡137.50), the golden angle.
The resulting pattern produces the most efficient packing of seeds within the flower head.
How well does this construction work?
How sensitive is the dependence on the value of the divergent angle?
It turns out the divergent angle cannot deviate by more than 0.04%.
1
Helmut Vogel, ”A Better Way to Construct the Sunflower Head”, Mathematical Bioscience,44, 179 (1979).
Increasing the divergent angle by 0.04%
Emphasis on Real Problem-Solving
At least 45 percent of undergraduates demonstrated ”no improvement in critical thinking, complex reasoning, and writing skills in the first two years of college” 2.
”36 percent showed no progress in four years”.
2
Richard Arum and Josipa Roksa,Academically Adrift: Limited Learning on College
Campuses, University of Chicago Press, 2011
Weak Mathematical and Problem-Solving Skills
The American work force has some of weakest mathematical and problem-solving skills in the developed world.
In a recent survey by a global policy organization, 3 adults in the United States scored far below average and better than only two of 12 other developed comparison countries, Italy and Spain.
Worse still, the United States is losing ground in worker training to countries in Europe and Asia whose schools are not just superior to ours but getting steadily better.
3Organization for Economic Cooperation and Development from 2011-2012
Problem with Real Problem-Solving
The 2003 National Assessment of Adult Literacy is a nationally
representative assessment of English literacy among American adults age 16 and older.
The study, sponsored by the National Center for Education Statistics, 4 is
the nation’s most comprehensive measure of adult literacy since the 1992 National Adult Literacy Survey.
Over 19,000 adults were asked to answer the following two problems:
4National Center for Education Statistics website: http://nces.ed.gov/NAAL.
Question 1: –
Refer to the advertisement for the Carpet Store on page three of the newspaper to answer the following question.
Suppose that you purchase DuPont Stainmaster carpet at the sale price. Using the calculator, compute how much in dollars and cents you would save per square yard over the regular price, excluding tax and labor.
Question 2: – Suppose that you want to carpet your living room which is 9 feet by 12 feet,
and you purchase DuPont Stainmaster carpet at the sale price. Using the calculator, compute the total cost, excluding tax and labor, of exactly enough carpet to cover your living room floor.
Problem with Real Problem-Solving (cont.)
It was found that only 62.9% of the adults answered the first question
correctly,
and only 17.6% correctly answered the second question.
The same questions were asked in a study conducted in 1992, with basically the same outcome.
Types of Problems in CS1133
Only word problems are used in CS1133. The following types of problems are not used
matching problems true-or-false problems fill-in-the-blank problems multiple-choice problems
Most the CS1133 problems are real-world problems.
General Guiding Principles
Whenever there is a freedom of choice, exercise ones choice wisely. Computer programs need to be modified and updated throughout its life history as newer versions. They must be written as flexible as possible (no hardwiring).
A programmer should not do anything that can be done by a computer.
General Problem-Solving Skills Emphasized
General problem-solving skills that have wide applications beyond computer programming are emphasized:
Read problem statement very carefully. Know what the given quantities are, the assumptions, and the form and type of output results.
If feasible, examine all possible solutions.
Try working forward from the given quantities and backward from the required output results.
Hand-check each step in the solution of the problem.
Solve a simplified version of the given problem. Make up a simplified version that one knows how to solve.
Example: while the sum is less than 1
Conduct the following computer experiment numerous times: Each time repeatedly pick a random number from 0 to 1 until the sum is no longer less than 1.
Find the average number of random numbers needed. Find the average sum.
0 1 2 3 4 5 0 0.5 1 1.5 2 n = 3 n = 2 n = 2 n = 4 n = 2
Stone slabs of random thicknesses are used to build a fence whose height must always be greater than 1 meter.
Example: Closer to the center
Find the fraction of points inside a square that lie closer to its center than to any one of its edges.
−1 −0.5 0 0.5 1 −1 −0.5 0 0.5 1 x y
A square castle surrounded by water in the middle of a lake.
To help the people who lives near the center of the castle, a well of a certain depth is to be dug.
To know how deep to dig, we need an estimation of the percentage of people who live near the well.
Example: Evaluate (1
x
)
6for a given
x
Use various di↵erent values of x and evaluate the following equivalent expressions:
1 x6 6x5+ 15x4 20x3+ 15x2 6x+ 1
2 (((((x 6)x+ 15)x 20)x+ 15)x 6)x+ 1
3 (1 x)6
Do they all give the same result?
Check the case where x is very close to 1.
If the three answers do not agree, which one do you trust?
Any polynomial can be written in the two equivalent forms as shown in expressions 1 and 2.
In general a polynomial is not expected to have a compact factorized form as shown in expression 3.
Example: Fraction of points within a hypercube that lies
near the edge?
Given a unit hypercube (a unit cube in an n-dimensional space), find the fraction of the points that lies near its edge
(within a distance of 0.01 from a boundary).
What happens as the dimension of space increases?
What does the result tell you about high-dimensional space?
Example: Average distance between 2 arbitrary points in a
hypercube
Find the average distance between two arbitrarily chosen points inside a hypercube.
What happens as the dimension of space increases?
What does the result tell you about high-dimensional space?
Example: Angle between 2 randomly chosen vectors in a
hypercube
Find the angles between pairs of arbitrarily chosen vectors lying inside a hypercube.
Try 20 pairs.
What happens as the dimension of space increases?
What does the result tell you about high-dimensional space?