1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# Algorithmic thinking
In engineering, solving a problem begins long before we start coding or building models. Like any other engineering challenge, computational problems must first be clearly framed and understood. In this section, you will learn to **apply algorithmic thinking** to systematically approach engineering problems, **translate real-world situations into structured programming logic**, and **use computational tools to implement, test, and refine solutions**.
Before diving into code, it's crucial to define the problem carefully, frame the problem so that logically so that a computer can understand then execute so that
## Define the Problem
As any other engineering problem, we need to frame it before we can start working on it. So before jumping straight into coding or building models, clearly define the engineering problem.
1. List your givens, this includes any constants or equations. What inputs do we know?
2. Find: List what you're trying to solve for. What outputs do we need to find?
3. Establish the assumptions based on your engineering knowledge that you deem to be appropriate to use for the problem. This determines what mathematical models we can apply to the problem (i.e. equations or formulas).
4. Solution: Show the works of the problem, this will include any code used together with documentation or any explanations of the code.
5. Comment: reflect and comment on your findings.
## Think Algorithmically
Since we are going to use computers to compute our calculate we first need to break the problem into logical steps that a computer can follow. This can be done with tools such as flowchart or psuedo-code.
- **Define the inputs and outputs.** What variables will the program take in, and what results will it produce?
- **Break the problem into sub-tasks.** Identify steps such as data input, logic processing and output.
- **Outline the algorithm.** Write pseudo-code or flowcharts that describe the computational steps.
- **Identify patterns or formulas.** Can loops, conditionals, or equations be used to automate parts of the solution?
### Flowchart for fixing lamp

### Psuedo-Code for processing and plotting stress-strain data:
1. Import force and displacement data from file.
2. Convert data from force and displacement to stress and strain.
3. Plot the stress-strain curve.
4. Identify the yield point or modulus.
## Write & Execute the Code
When writing the code it is important to ask yourself whether you're using the right tools, libraries or method to solve the problem. **Check for any syntax and logic errors** then debug line-by-line using print statements or by using a debugging tool.
## Verify and Validate
When writing code it is crucial to test and confirm your code. It is therefore important to ask yourself the following questions. Does the code do what you intended it to do? And, is the mathematical model used in the code valid for the current problem?
## Exercise: Design a derivative finding algorithm
Set up the problem and write pseudo-code to calculate the gradient of an unknown function.
1. **Given:**
2. **Find:
3. **Assumptions:**
4. **Solution:**
5. **Comment:**
|