Numerical Method · Unit 3 · 8 hrs
Numerical Differentiation and Integration
Exam-focused notes for Numerical Differentiation and Integration (Numerical Method, CSC212): what the TU syllabus asks and how it has actually been tested, with 11 solved past questions from this unit.
Numerical Differentiation and Integration in short
This chapter turns a function, whether given as a formula or only as a table of values, into an estimate of its derivative or its definite integral, using nothing but arithmetic on sampled values.
What this unit covers
- Differentiating Continuous Functions (Two-Point and Three-Point Formula)
- Differentiating Tabulated Functions by using Newton's Differences
- Maxima and minima of Tabulated Functions
- Newton-Cote's Quadrature Formulas
- Trapezoidal rule
- Multi-Segment Trapezoidal rule
- Simpson's 1/3 rule
- Multi-Segment Simpson's 1/3 rule
- Simpson's 3/8 rule
- Multi-Segment Simpson's 3/8 rule
- Gaussian integration algorithm
- Romberg integration
Differentiating Tabulated Functions by using Newton's Differences
2081 · 5 marks
What is numerical differentiation? The table below gives the values of distance travelled by a vehicle at various time intervals. Estimate the velocity and acceleration at $x=4$.
| Time $(x)$ | 1 | 2 | 4 | 8 | 10 |
|---|---|---|---|---|---|
| Distance $(y)$ | 0 | 1 | 5 | 21 | 27 |
[5]
Show solved answerHide answer
Numerical Differentiation
Definition
Numerical differentiation is the process of estimating the derivative (rate of change) of a function from a set of tabulated/discrete data values, instead of differentiating a closed-form expression analytically. It is used when the function is either unknown (only data points are given) or too complex to differentiate directly. The derivatives are obtained by differentiating an interpolating polynomial (Newton forward/backward for equal spacing, Newton's divided differences for unequal spacing).
Here velocity $= \dfrac{dy}{dx}$ and acceleration $= \dfrac{d^2y}{dx^2}$.
Given Data
| Time $x$ | 1 | 2 | 4 | 8 | 10 |
|---|---|---|---|---|---|
| Distance $y$ | 0 | 1 | 5 | 21 | 27 |
The nodes are unequally spaced, so I use Newton's Divided Difference interpolation.
Step 1: Divided Difference Table
First DD: $$f[x_0,x_1]=\tfrac{1-0}{2-1}=1,\quad f[x_1,x_2]=\tfrac{5-1}{4-2}=2$$ $$f[x_2,x_3]=\tfrac{21-5}{8-4}=4,\quad f[x_3,x_4]=\tfrac{27-21}{10-8}=3$$
Second DD: $$f[x_0,x_1,x_2]=\tfrac{2-1}{4-1}=\tfrac13,\quad f[x_1,x_2,x_3]=\tfrac{4-2}{8-2}=\tfrac13,\quad f[x_2,x_3,x_4]=\tfrac{3-4}{10-4}=-\tfrac16$$
Third DD: $$f[x_0,x_1,x_2,x_3]=\tfrac{\tfrac13-\tfrac13}{8-1}=0,\quad f[x_1,x_2,x_3,x_4]=\tfrac{-\tfrac16-\tfrac13}{10-2}=\tfrac{-\tfrac12}{8}=-\tfrac1{16}$$
Fourth DD: $$f[x_0,\dots,x_4]=\tfrac{-\tfrac1{16}-0}{10-1}=-\tfrac1{144}$$
Step 2: Newton's Divided Difference Polynomial
$$P(x)=(x-1)+\tfrac13(x-1)(x-2)+0-\tfrac1{144}(x-1)(x-2)(x-4)(x-8)$$
Step 3: Velocity = $P'(4)$
Term 1: $\dfrac{d}{dx}(x-1)=1$
Term 2: $\dfrac13\big[(x-2)+(x-1)\big]=\dfrac13(2x-3)$; at $x=4$: $\dfrac13(5)=\dfrac53$
Term 3: coefficient $0\Rightarrow 0$
Term 4: Let $g(x)=(x-1)(x-2)(x-4)(x-8)$. $$g'(x)=(x-2)(x-4)(x-8)+(x-1)(x-4)(x-8)+(x-1)(x-2)(x-8)+(x-1)(x-2)(x-4)$$ At $x=4$, only the term without $(x-4)$ survives: $$g'(4)=(3)(2)(-4)=-24$$ Contribution $=-\dfrac1{144}(-24)=\dfrac{1}{6}$
Velocity: $$P'(4)=1+\tfrac53+0+\tfrac16=\frac{6+10+1}{6}=\frac{17}{6}\approx 2.833$$
$$\boxed{\text{Velocity}\approx 2.83\ \text{units/time}}$$
Step 4: Acceleration = $P''(4)$
Term 1: second derivative $=0$
Term 2: $\dfrac13(2x-3)\Rightarrow \dfrac13(2)=\dfrac23$
Term 3: $0$
Term 4: Need $g''(4)$ where $g(x)=(x-1)(x-2)(x-4)(x-8)$.
Differentiate $g'(x)$ (sum of four triple products). $g''(x)$ is the sum of all products of two factors, each taken from three of the roots. A cleaner way: expand near the surviving structure. Since terms with $(x-4)$ vanish in first derivative, for $g''$ we differentiate:
$$g'(x)=\underbrace{(x-2)(x-4)(x-8)}{A}+\underbrace{(x-1)(x-4)(x-8)}{B}+\underbrace{(x-1)(x-2)(x-8)}{C}+\underbrace{(x-1)(x-2)(x-4)}{D}$$
At $x=4$:
- $A'=(x-4)(x-8)+(x-2)(x-8)+(x-2)(x-4)$; at 4: $0+(2)(-4)+0=-8$
- $B'=(x-4)(x-8)+(x-1)(x-8)+(x-1)(x-4)$; at 4: $0+(3)(-4)+0=-12$
- $C'=(x-2)(x-8)+(x-1)(x-8)+(x-1)(x-2)$; at 4: $(2)(-4)+(3)(-4)+(3)(2)=-8-12+6=-14$
- $D'=(x-2)(x-4)+(x-1)(x-4)+(x-1)(x-2)$; at 4: $0+0+(3)(2)=6$
$$g''(4)=-8-12-14+6=-28$$
Contribution $=-\dfrac1{144}(-28)=\dfrac{28}{144}=\dfrac{7}{36}$
Acceleration: $$P''(4)=0+\tfrac23+0+\tfrac{7}{36}=\frac{24+7}{36}=\frac{31}{36}\approx 0.861$$
$$\boxed{\text{Acceleration}\approx 0.86\ \text{units/time}^2}$$
Final Results
- Velocity at $x=4$: $\dfrac{17}{6}\approx 2.83$
- Acceleration at $x=4$: $\dfrac{31}{36}\approx 0.86$
2080 · 5 marks
How can we calculate derivatives of discrete (tabulated) functions? Write down its algorithm. [5]
Simpson's 3/8 rule
2081 · 5 marks
What is an application of numerical integration? Find the value of the integral using Simpson's 3/8 rule with n=6. $$\int_{1}^{2} \frac{e^x}{x} dx$$ [5]
Show solved answerHide answer
Application of Numerical Integration and Simpson's 3/8 Rule
Application of Numerical Integration
Numerical integration computes the approximate value of a definite integral from numerical/tabular values of the integrand. Key application:
- Evaluating definite integrals when no closed-form (analytical) antiderivative exists (such as $\int e^{x}/x,dx$).
- Computing area/volume from experimental or tabular data where only discrete points are known.
- Used in engineering and physics for work, probability, signal processing, etc.
Given Data
$$\int_1^2 \frac{e^x}{x},dx, \qquad a=1,\ b=2,\ n=6$$
Since $n=6$ is a multiple of 3, Simpson's 3/8 rule applies.
Step 1: Step size
$$h = \frac{b-a}{n} = \frac{2-1}{6} = \frac{1}{6} = 0.16667$$
Step 2: Nodes and function values $f(x)=\dfrac{e^x}{x}$
| $i$ | $x_i$ | $e^{x_i}$ | $f(x_i)=e^{x_i}/x_i$ |
|---|---|---|---|
| 0 | 1.00000 | 2.71828 | 2.71828 |
| 1 | 1.16667 | 3.21109 | 2.75236 |
| 2 | 1.33333 | 3.79367 | 2.84525 |
| 3 | 1.50000 | 4.48169 | 2.98779 |
| 4 | 1.66667 | 5.29449 | 3.17670 |
| 5 | 1.83333 | 6.25514 | 3.41190 |
| 6 | 2.00000 | 7.38906 | 3.69453 |
Step 3: Simpson's 3/8 composite rule
$$I \approx \frac{3h}{8}\Big[f_0 + 3(f_1+f_2+f_4+f_5) + 2f_3 + f_6\Big]$$
Grouping:
- $f_0 + f_6 = 2.71828 + 3.69453 = 6.41281$
- $3(f_1+f_2+f_4+f_5) = 3(2.75236+2.84525+3.17670+3.41190) = 3(12.18621)=36.55863$
- $2f_3 = 2(2.98779) = 5.97558$
Sum $= 6.41281 + 36.55863 + 5.97558 = 48.94702$
Step 4: Coefficient and result
$$\frac{3h}{8} = \frac{3\times 0.16667}{8} = \frac{0.50001}{8} = 0.0625$$
$$I \approx 0.0625 \times 48.94702 = 3.05919$$
$$\boxed{I \approx 3.0592}$$
The exact value is $\approx 3.0591$, so the approximation is accurate to 4 significant figures.
Multi-Segment Trapezoidal rule
2080 · 5 marks
Find the following integral using composite trapezoidal rule for using 2 segments (k=2) and 4 segments (k=4). $$\int_{2}^{4} (x^3 + 2) dx$$ [5]
Multi-Segment Simpson's 1/3 rule
2079 · 5 marks
Simpson's 1/3 Rule Integration
Estimate the integral value of the following function from $x = 1.2$ to $x = 2.4$ using Simpson's 1/3 rule.
$$\begin{array}{c|cccccccc} x & 1.0 & 1.2 & 1.4 & 1.6 & 1.8 & 2.0 & 2.2 & 2.4 & 2.6 \ \hline f(x) & 1.53 & 2.25 & 3.18 & 4.32 & 5.67 & 7.23 & 8.98 & 10.94 & 13.08 \end{array}$$
[5]
Gaussian integration algorithm
2079 · 5 marks
What is Gaussian integration formula? Evaluate the following integration using Gaussian integration three ordinate formula. $$\int_{0}^{1} \frac{\sin x}{x} dx$$ [5]
Romberg integration
2078 · 5 marks
Evaluate the following integration using Romberg integration. $$\int_{0}^{1} \frac{\sin^2 x}{x} dx$$ [5]
2075 · 5 marks
Evaluate the following integration using Romberg integration. $$\int_{0}^{1} \frac{\sin x}{x} dx$$ [5]
Differentiating Continuous Functions
2077 · 5 marks
Write down algorithm and program for the differentiating continuous function using three point formula. [5]
Simpson's 1/3 rule
2077 · 5 marks
How Simpson's 1/3 rule differs from Trapezoidal rule? Drive the formula for Simpson's 1/3 rule. [5]
2075 · 5 marks
Calculate the integral value of the function given below from $x = 1.8$ to $x = 3.4$ using Simpson's 1/3 rule.
$$\begin{array}{c|cccccccc} x & 1.8 & 2.0 & 2.2 & 2.4 & 2.6 & 2.8 & 3.0 & 3.4 \ \hline f(x) & 0.003 & 0.778 & 1.632 & 2.566 & 3.579 & 4.672 & 7.097 & 8.429 \end{array}$$
[5]
Make Unit 3 stick
Practice CSC212 with flashcards & quizzes