Problems to be Solved using Simulation
Many times computer programmers are confronted with problems that may be solved by an expert in a specific discipline but whose solution is not obvious to the non-professional in that discipline. Oftentimes a programmer may use simple simulation techniques to discover a likely answer to such problems. The simulation may not be "proof" but it often reveals the answer and simetimes even a method of proving the answer so discovered. A program also has the advantage of displaying convincing intermediate results that enhance confidence in the methods employed.
Typically many problems are based upon "real-life" situations. Using simulation to solve such problems is a mulitstage process. First the real-life problem must be converted into a mathematical form. Next, an algorithm must be constructed to simulate the mathematical process. Then the algorithm must be converted into a computer program. And, finally, the results should be observed and verified however possible.
Zero to the Zero
We all learned back in high school or earlier that if zero is raised to any power then the result is zero. We also learned that any number raised to the zero power is one. In the case of zero raised to the zero power we are then presented with a dilemma. By the first rule given above zero raised to the zero power should be zero but by the second rule it should be one.
The solution to this problem can be found by using Calculus to find the lim(XX). It is, however, instructive to write a program to display values of XX as X approaches 0 from the positive side.
Write a program to discover the lim(XX) and create a user interface (intermediate results, graphs, etc.) to bolster confidence in the final result.
Distance to the Nearest City
Although this problem can be stated entirely geometrically it is more interesting to wrap the puzzle into a hypothetical situation.
In the dark of night a pilot takes off in an airplane from village A in Australian desert country and flies in a straight line toward city B. A and B are 50 miles apart. During the flight the engine fails and he must parachute out of the aircraft onto the desert below. He can determine from the stars which direction it is to A and to B but does not know what city is closest. On the average does it matter what direction he chooses? I.e., is he likely to be much closer to one city than the other.
Stated geometrically, if a point is selected randomly on a line segment of length one what is the average distance from the point to the nearest endpoint on the line segment?
Write a program to discover the average minimum distance. Convincingly support your simulation approach to bolster confidence in the final result.
Min, Max and Average Line Segment Sizes
Two points are selected randomly on a line segment of size one. The two points divide the line segment into three smaller segments.
Write a program to determine the average size of the smallest and the largest segments as well as the overall average size of all segments so created. Convincingly support your simulation approach to bolster confidence in the final result.
The Plus One - Minus One Problem
Again, we will create a situation in which to place the puzzle to make it more interesesting.
A man stands on a long sidewalk that runs east/west. He flips a fair coin to determine in which direction to step. If the coin comes up heads he takes one step (moves one meter) east. If the coin comes up tails he takes one step (moves one meter) west. After N coin flips how far from the origin, on the average, is the man?
Stated another way,
Initialize the value of variable "DISTANCE" to 0.
Repeat the following in a loop N times.
Choose the number +1 or -1 randomly and place the value in variable "INC".
Add INC to DISTANCE.
Write a program to determine the average distance from the origin after N iterations. If you cannot determine a formula for DISTANCE as a function of N then create a chart and graph that shows how DISTANCE grows as N grows. This will require that you run the simulation for many different values of N.
You should be able to compute the correct average distance for small values of N without running the simulation. For example, if N = 1 then DISTANCE = 1.
Try to discover a pattern/approximation from the chart or graph.
Top of this page
Home page 
