UPSC 2014 Maths Optional Paper 2 Q7b — Step-by-Step Solution
15 marks · Section B
Question
Draw a flowchart for Simpson’s one-third rule.
Technique
Standard composite Simpson’s 1/3 rule implementation; flowchart with input validation, accumulator-loop, and output.
Solution
Algorithm. Composite Simpson’s 1/3 rule approximates using subintervals (with even) of width . The formula is
Flowchart (textual ASCII rendering)
┌─────────────┐
│ START │
└──────┬──────┘
▼
┌────────────────────────────────────────────┐
│ READ: │
│ f(x), a (lower limit), b (upper limit), │
│ n (even integer, number of subintervals) │
└──────────────────┬─────────────────────────┘
▼
┌─────────────────────────┐
│ IS n EVEN? │
└────┬───────────────┬────┘
No │ Yes│
▼ ▼
┌──────────┐ ┌──────────────────┐
│ PRINT: │ │ Compute h=(b-a)/n│
│ "n must │ │ Initialize: │
│ be even"│ │ sum = f(a)+f(b)│
│ STOP │ │ i = 1 │
└──────────┘ └────────┬─────────┘
▼
┌──────────────────────────────────┐
│ LOOP: WHILE i ≤ n-1 │
│ x_i = a + i*h │
│ IF i is ODD: │
│ sum = sum + 4*f(x_i) │
│ ELSE (i EVEN): │
│ sum = sum + 2*f(x_i) │
│ i = i + 1 │
└─────────────┬────────────────────┘
▼
┌──────────────────────────────┐
│ integral = (h/3) * sum │
└──────────────┬───────────────┘
▼
┌──────────────────────────┐
│ PRINT integral │
└──────────────┬───────────┘
▼
┌────────┐
│ STOP │
└────────┘
Verbal description of steps
-
Input: function , interval , even integer .
-
Validate : if odd, abort with error.
-
Compute step size: .
-
Initialise accumulator: (endpoint contributions, weight 1).
-
Loop through interior points :
- Compute .
- If is odd: add to sum.
- If is even: add to sum.
-
Combine: .
-
Output the integral value and stop.