Programming Concepts: Simulations

From Wikibooks, open books for an open world
Jump to: navigation, search

UNIT 3 - ⇑ Programming Concepts ⇑

← Hashing Simulations

Simulation - A mathematical representation of reality

One of the main uses of computers is to simulate real life scenarios. You might have made a spreadsheet at school to simulate the amount of money made by a shop, or driven a formula one car on your console at home. Some of the most powerful computers in the world are used to simulate complex phenomena including

  • Financial models
  • Weather
  • Nuclear explosions
  • Coastal erosion

If you ever watch the weather forecast all the predictions are made by software simulating weather patterns. If you ever wonder why there aren't so many nuclear tests any more, there is no need as computers can simulate what happens.

Chaos Theory[edit]

With such powerful computers simulating models you might question why we are so bad at predicting the weather and how simulations can give the wrong results. This may be because the model being used is set up in completely the wrong way, but it may also be a result of chaos theory. Chaos theory states that any tiny differences in the initial starting conditions (such as those due to rounding errors in numerical computation) will have a huge effect on how the system performs in the long run. Rendering long-term prediction impossible in general. This can be seen in the inability of weather forecasts to get long term forecasts correct. This is also known through the butterfly effect, where Philip Merilees stated "Does the flap of a butterfly’s wings in Brazil set off a tornado in Texas?"

Exercise: Simulations

What is a simulation?

Answer :

The imitation of a process of a real system.

Give two examples of models that are simulated

Answer :

  • Formula one racing car designs
  • nuclear bomb tests
  • weapons
  • weather patterns

Give one reason why simulation might not work in the long term:

Answer :

- The margin of error increases over time, as more variables interact with the system, causing errors and unforeseen circumstances that could enter the system, causing it to stop accurately working in the long term.

A petrol station needs to model the number of vehicles it can serve petrol in a day. It can serve petrol and diesel and often has queues for each pump. Name the entities and attributes of each entity.

Answer :


  • vehicle
    • type
    • fuel type
    • fuel level
    • being served
    • payed
  • pump
    • busy
    • diesel working
    • petrol working
  • staff
    • serving
    • speed of serving