Chapter 10 Numerical Methods Notes – 12th Class Math Federal Board

Chapter 10 Numerical Methods notes thumbnail listing the exercises of the chapter, 12th class math Federal Board (FBISE)

Chapter 10, Numerical Methods, from the 12th class Mathematics, Federal Board (FBISE) book. These notes cover Importance of Numerical Methods, The Role of Numerical Methods, Computers and Numerical Methods, Basic Principle of Solving Non-linear Equations, Bisection Method, Regula Falsi Method, Newton’s Raphson Method, Numerical Integration and Simpson’s One-Third Rule. Learn the definitions and formula boxes, then try the solved examples and the exercises.

Tap a section to open or close it.
10.1 Importance of Numerical Methods

Numerical methods give approximate answers by repeated arithmetic. We use them when an exact answer is impossible, or too hard to find by direct (analytical) methods. They are used in science, engineering and finance.

  • Integrals. Some functions have no simple antiderivative. For example, $\int e^{-x^2}\,dx$ (the Gaussian integral) cannot be written with basic functions. The trapezoidal rule and Simpson’s rule can give its approximate value between two limits.
  • Non-linear equations. Some equations cannot be solved by algebra. For example, $\sin x+e^x+\ln x+x=0$. The bisection, Regula Falsi and Newton–Raphson methods find its root step by step.

Each repetition of the calculation is called an iteration. The value found in it is also called an iterate. The answer is often close enough for practical use.

History. Modern numerical analysis is often linked to a 1947 paper by John von Neumann and Herman Goldstine. Some writers trace it back to E. T. Whittaker in 1912.

10.2 The Role of Numerical Methods

Numerical methods are important because they do four things.

  • Approximate solutions. They give a close answer when the exact answer cannot be found.
  • Automate repeated calculations. They break a hard problem into a series of simple, repeated calculations. A computer can do these quickly.
  • Adapt to new technology. They become more powerful as computers improve.
  • Handle complex systems. They can solve systems of equations, partial differential equations and non-linear equations.
10.3 Computers and Numerical Methods

Computers are ideal for numerical methods because they do a large number of calculations quickly and accurately. Problems that would take too long by hand become possible.

With a calculator, follow the same idea.

  • Write the starting values and the formula.
  • Repeat the same formula with the newest values.
  • Keep the full values in the calculator. Round only the final answer.
10.4 Basic Principle of Solving Non-linear Equations

First write the equation in the form $f(x)=0$.

Roots or zeros. The roots (or zeros) of $f(x)=0$ are the values of $x$ that make $f(x)$ equal to zero. For example, $x^2+5x+6=0$ has the roots $x=-2$ and $x=-3$. These are found by a direct (analytical) method.

Types of functions

  • Linear function: $f(x)=ax+b$. Its root is easy to find by a direct method.
  • Algebraic (polynomial) function of degree $n$: $f(x)=a_nx^n+a_{n-1}x^{n-1}+a_{n-2}x^{n-2}+\cdots+a_0$. If the degree is higher than four, direct methods are difficult and often impractical.
  • Transcendental function: it contains trigonometric, exponential or logarithmic terms. For example, $e^x+\sin x+4=0$, $e^x+\ln x-7=0$ and $\tan x+x^3+x^2+10=0$. Direct methods usually fail for these equations.
Common mistake / Note: The book prints the first term of the polynomial as $a_nx_n$. It should be $a_nx^n$.

Methods used in this unit

Direct methods often fail for non-linear equations, so we find approximate roots. Each method has its own advantages and limitations. This unit uses three methods.

  • Bisection method
  • Regula Falsi method
  • Newton–Raphson method
Sign-Change Theorem · p. 278If $f(x)$ is continuous on the closed interval $[a,b]$ and $f(a)$, $f(b)$ have opposite signs, then the equation $f(x)=0$ has at least one real root between $a$ and $b$.

Why it is true

One of the numbers $f(a)$, $f(b)$ is negative and the other is positive. So $0$ lies between them. A continuous function takes every value between $f(a)$ and $f(b)$ (Intermediate Value Theorem). So $f(x)=0$ for some $x$ between $a$ and $b$.

A continuous curve crosses the x-axis between a and b
$x$
$y$
$4$
$-2$
$-1$
$1$
$2$
$O$
$a$
$b$
$f(a)$
$f(b)$
$\text{root}$
  • $y=f(x)$
$f(a)$ is negative and $f(b)$ is positive. The curve has no break, so it cuts the $x$-axis between $a$ and $b$.

Worked illustration. Take $f(x)=x^2-2$ on $[1,2]$.

$$\begin{aligned}f(1)&=1^2-2=-1\ (-\text{ve})\\[7pt]f(2)&=2^2-2=2\ (+\text{ve})\end{aligned}$$

The signs are opposite, so $x^2-2=0$ has a root between $1$ and $2$.

Common mistake / Note: The curve must have no break between $a$ and $b$. If it has a break, opposite signs do not prove that there is a root. For example, $f(x)=\dfrac1x$ has opposite signs at $-1$ and $1$, but it has no root.
10.5 Bisection Method

The bisection method needs two starting values $x_0$ and $x_1$ with $f(x_0)f(x_1)<0$. Then $f(x)=0$ has at least one root between $x_0$ and $x_1$. We cut the interval into two halves again and again. The midpoints are $x_2,x_3,\ldots$

Bisection formula
$$x_2=\frac{x_0+x_1}{2}$$
  • Step 1. Find $x_2=\dfrac{x_0+x_1}{2}$ and then $f(x_2)$.
  • Step 2. If $f(x_2)=0$, then $x_2$ is a root. Stop.
  • Step 3. If $f(x_0)f(x_2)<0$, the root lies between $x_0$ and $x_2$. Take $x_3=\dfrac{x_0+x_2}{2}$.
  • Step 4. If $f(x_1)f(x_2)<0$, the root lies between $x_1$ and $x_2$. Take $x_3=\dfrac{x_1+x_2}{2}$.
  • Step 5. Repeat with the new values until the root has the required accuracy.

When $f(x_2)\ne0$, only one of Step 3 and Step 4 is possible. This method is simple but slow. It is also called the interval halving method or the binary-search method.

Common mistake / Note: If the two starting values are not given, find two values of $x$ where $f(x)$ has opposite signs.
First midpoint of the bisection method
$x$
$y$
$3$
$-2$
$-1$
$1$
$2$
$3$
$4$
$O$
$x_0$
$x_2$
$x_1$
$f(x_0)$
$f(x_2)$
$f(x_1)$
  • $y=f(x)$
Bisection for $f(x)=x^2-2$ with $x_0=1$ and $x_1=2$. The midpoint is $x_2=1.5$.

Worked illustration. Let $f(x)=x^2-2$; $x_0=1$, $x_1=2$. Here $f(x_0)=-1$ $(-\text{ve})$ and $f(x_1)=2$ $(+\text{ve})$.

$$\begin{aligned}x_2&=\frac{x_0+x_1}{2}=\frac{1+2}{2}=1.5\\[7pt]f(x_2)&=(1.5)^2-2=0.25\ (+\text{ve})\end{aligned}$$

The root lies between $x_0$ and $x_2$, that is, between $1$ and $1.5$.

$$\begin{aligned}x_3&=\frac{x_0+x_2}{2}=\frac{1+1.5}{2}=1.25\\[7pt]f(x_3)&=(1.25)^2-2=-0.4375\ (-\text{ve})\end{aligned}$$

The root lies between $x_2$ and $x_3$, that is, between $1.25$ and $1.5$.

Length of the interval

After $k$ halvings the length of the interval is

$$\frac{x_1-x_0}{2^k}$$

When to stop. For an answer correct to $2$ decimal places, continue until both ends of the interval round to the same $2$-decimal value. For example, if the root lies between $1.413$ and $1.414$, it is $1.41$ to two decimal places.

Common mistake / Note: The two values you keep must always give opposite signs of $f(x)$.
Bisection method: advantages and limitations

Advantages

  • It is simple and reliable.
  • It always reaches a root if the continuous function changes sign over the interval.

Limitations

  • It can be slow, especially if high accuracy is needed.
  • We must first know an interval where the sign changes.
10.6 Regula Falsi Method

This is also called the method of false position. It needs two starting values $x_0$ and $x_1$ with $f(x_0)f(x_1)<0$. Join the points $(x_0,f(x_0))$ and $(x_1,f(x_1))$ by a straight line (a chord). The new value $x_2$ is the point where this chord cuts the $x$-axis.

Regula Falsi formula
$$x_2=\frac{x_0f(x_1)-x_1f(x_0)}{f(x_1)-f(x_0)}$$

In general, for $n=1,2,3,\ldots$

$$x_{n+1}=\frac{x_{n-1}f(x_n)-x_nf(x_{n-1})}{f(x_n)-f(x_{n-1})}$$

Provided $f(x_n)f(x_{n-1})<0$.

After each step find the sign of $f$ at the new value. Use the new value with the earlier value that gives the opposite sign.

The chord cuts the x-axis at the new value
$x$
$y$
$3$
$-2$
$-1$
$1$
$2$
$3$
$4$
$O$
$x_0$
$x_1$
$x_2$
$f(x_0)$
$f(x_1)$
  • $y=f(x)$
  • $\text{Chord}$
Regula Falsi for $f(x)=x^2-2$ with $x_0=1$ and $x_1=2$. The chord cuts the $x$-axis at $x_2=\dfrac43$.

Where the formula comes from

The points $(x_0,f(x_0))$, $(x_2,0)$ and $(x_1,f(x_1))$ are on the same line. So the slopes are equal.

$$\frac{0-f(x_0)}{x_2-x_0}=\frac{f(x_1)-f(x_0)}{x_1-x_0}$$

Solve for $x_2$.

$$\begin{aligned}x_2-x_0&=-\frac{(x_1-x_0)f(x_0)}{f(x_1)-f(x_0)}\\[7pt]x_2&=x_0-\frac{(x_1-x_0)f(x_0)}{f(x_1)-f(x_0)}\\[7pt]&=\frac{x_0f(x_1)-x_1f(x_0)}{f(x_1)-f(x_0)}\end{aligned}$$

The values $f(x_0)$ and $f(x_1)$ have opposite signs, so the denominator is not zero.

Worked illustration. Let $f(x)=x^2-2$; $x_0=1$, $x_1=2$. Here $f(x_0)=-1$ $(-\text{ve})$ and $f(x_1)=2$ $(+\text{ve})$.

$$\begin{aligned}x_2&=\frac{x_0f(x_1)-x_1f(x_0)}{f(x_1)-f(x_0)}\\[7pt]&=\frac{1(2)-2(-1)}{2-(-1)}=\frac43\\[7pt]f(x_2)&=\left(\frac43\right)^2-2=-\frac29\ (-\text{ve})\end{aligned}$$

The root lies between $x_1$ and $x_2$, that is, between $\dfrac43$ and $2$.

Convergence. This method may be faster than the bisection method. One drawback is that one end point may not move. Then the values come closer to the root from one side only.

When to stop. Continue until two successive values agree to the required number of decimal places. Then check the sign of $f(x)$ near the rounded value to be sure.

Regula Falsi method: advantages and disadvantages

Advantages

  • It converges to a root if $f$ is continuous and the starting values give opposite signs.
  • It is often faster than bisection.

Disadvantages

  • It can be slow in some cases.
  • It does not work for all functions. It may fail to find a root if the starting values do not give opposite signs, or if the function has several roots.
10.7 Newton’s Raphson Method

Newton’s Raphson method needs one starting value $x_0$ and the derivative $f'(x)$. It is also called the method of tangents. The new value is the point where the tangent to the curve cuts the $x$-axis.

Newton’s Raphson formula
$$x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)},\quad n=0,1,2,\ldots$$

Here $f'(x_n)\ne0$.

Derivation · pp. 282–283

Let $x_0$ be an approximate root of $f(x)=0$. Let $x_0+h$ be the exact root, where $h$ is small. Then

$$f(x_0+h)=0$$

Expand by Taylor’s theorem.

$$f(x_0)+hf'(x_0)+\frac{h^2}{2!}f''(x_0)+\cdots=0$$

Since $h$ is small, neglect the terms with $h^2$ and higher powers of $h$. Now $h$ is only approximate.

$$\begin{aligned}f(x_0)+hf'(x_0)&=0\\[7pt]h&=-\frac{f(x_0)}{f'(x_0)},\quad f'(x_0)\ne0\end{aligned}$$

So the first better value is

$$x_1=x_0+h=x_0-\frac{f(x_0)}{f'(x_0)}$$

Put $x_1$ in place of $x_0$ to get the next value, and so on.

$$x_2=x_1-\frac{f(x_1)}{f'(x_1)},\qquad x_3=x_2-\frac{f(x_2)}{f'(x_2)}$$

After $n$ steps we get the general formula.

$$x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}$$
Tangents in Newton's Raphson method
$x$
$y$
$4$
$-2$
$2$
$4$
$6$
$8$
$O$
$x_0$
$x_1$
$x_2$
$f(x_0)$
$f(x_1)$
  • $y=f(x)$
  • $\text{Tangents}$
Newton’s Raphson method for $f(x)=x^2-2$ with $x_0=3$. Each tangent cuts the $x$-axis closer to the root $\sqrt2$.

Worked illustration. Let $f(x)=x^2-2$ and $x_0=3$. Then $f'(x)=2x$.

$$\begin{aligned}x_{n+1}&=x_n-\frac{x_n^2-2}{2x_n}\\[7pt]&=\frac{x_n^2+2}{2x_n}\end{aligned}$$
$$\begin{aligned}x_1&=\frac{3^2+2}{2(3)}\approx1.8333\\[7pt]x_2&\approx\frac{(1.8333)^2+2}{2(1.8333)}\approx1.4621\\[7pt]x_3&\approx\frac{(1.4621)^2+2}{2(1.4621)}\approx1.4150\\[7pt]x_4&\approx\frac{(1.4150)^2+2}{2(1.4150)}\approx1.4142\end{aligned}$$

The exact root is $\sqrt2\approx1.4142$.

In the examples and exercises, first simplify $x_n-\dfrac{f(x_n)}{f'(x_n)}$ into one fraction, as above. Then put the values in it.

Points to remember

  • If the slope $f'(x_n)$ is large, $h$ is small and the root is found in less time.
  • If $x_0$ is close to the root, the root is found very quickly.
  • The method fails if $f'(x_n)=0$. It may also fail if $f'$ is zero near the root. Then use the Regula Falsi method.
  • If $x_0$ is not given, choose two values $a$ and $b$ such that $f(a)$ and $f(b)$ have opposite signs. If $|f(a)|<|f(b)|$, take $a$ as the starting value.
Common mistake / Note: The book prints the condition as $|f(a)<f(b)|$. It means $|f(a)|<|f(b)|$.
Common mistake / Note: For $f(x)=x^2-2$, do not start at $x_0=0$, because $f'(0)=0$.

When to stop. Continue until two successive values agree to the required number of decimal places.

Newton’s Raphson method: advantages and disadvantages

Advantages

  • It converges rapidly.
  • It can be used for many kinds of equations.

Disadvantages

  • It needs the derivative.
  • It depends on the starting value. A poor starting value may lead to another root or to no root.
10.8 Numerical Integration

Numerical integration means finding $\int_a^b y\,dx$ when $y=f(x)$ is given by a table of values $(x_i,y_i)$, $i=0,1,2,\ldots,n$, with $a=x_0$ and $b=x_n$. For a function of one variable this process is also called quadrature. We replace $f(x)$ by a simpler function that passes through the given points, and integrate that function.

Equal parts
$$h=\frac{b-a}{n}$$
$$x_1=x_0+h,\quad x_2=x_0+2h,\quad\ldots,\quad x_n=x_0+nh=b$$

10.8.1 Trapezoidal rule

Divide $[a,b]$ into $n$ equal parts of width $h$. Join the points of the curve by straight lines. Each strip becomes a trapezium.

Trapezoidal rule
$$\int_a^bf(x)\,dx\approx\frac h2\left[(y_0+y_n)+2(y_1+y_2+\cdots+y_{n-1})\right]$$

The answer of this rule with $n$ parts is also written $T_n$.

Derivation · pp. 285–286

The area of a trapezium is its width times the average of its two parallel sides.

$$\begin{aligned}\int_{x_0}^{x_0+h}f(x)\,dx&\approx\frac h2[y_0+y_1]\\[7pt]\int_{x_0+h}^{x_0+2h}f(x)\,dx&\approx\frac h2[y_1+y_2]\end{aligned}$$

In the same way, the last strip gives

$$\int_{x_0+(n-1)h}^{x_0+nh}f(x)\,dx\approx\frac h2[y_{n-1}+y_n]$$

Add these $n$ integrals. Each middle value comes twice. The first and last values come once.

$$\int_{x_0}^{x_0+nh}f(x)\,dx\approx\frac h2\left[(y_0+y_n)+2(y_1+y_2+\cdots+y_{n-1})\right]$$

This is also called the multiple segment or composite trapezoidal rule. The answer usually improves when $h$ is made smaller (more parts).

Worked illustration. Take $f(x)=x^2$ on $[0,2]$ with $n=2$. Then $h=1$, $y_0=0$, $y_1=1$ and $y_2=4$.

$$\int_0^2x^2\,dx\approx\frac12\left[(0+4)+2(1)\right]=3$$
Two trapezia for the integral of x squared
$x$
$y$
$-0.5$
$0.5$
$1$
$1.5$
$2$
$2.5$
$1$
$2$
$3$
$4$
$O$
$(1, 1)$
$(2, 4)$
  • $y=x^2$
  • $\text{Straight edges}$
The two strips of width $h=1$. The first strip is a triangle because $y_0=0$. The height $y_1=1$ belongs to both strips.
Common mistake / Note: Count the parts, not the values. Three values give two parts.
10.9 Simpson’s One-Third Rule

Use this rule only when the number of parts $n$ is even.

Simpson’s one-third rule
$$\begin{aligned}\int_a^bf(x)\,dx\approx\frac h3\big[&(y_0+y_n)+4(y_1+y_3+\cdots+y_{n-1})\\[5pt]&+2(y_2+y_4+\cdots+y_{n-2})\big]\end{aligned}$$

It is also called Simpson’s rule. Its answer with $n$ parts is also written $S_n$. The proof is not needed at this level.

  • The first and last values are taken once.
  • The odd values $y_1,y_3,\ldots$ are multiplied by $4$.
  • The other even values $y_2,y_4,\ldots$ are multiplied by $2$.

Simpson’s rule usually gives a more accurate result than the trapezoidal rule.

Worked illustration. Take $f(x)=x^2$ on $[0,2]$ with $n=2$. Then $h=1$, $y_0=0$, $y_1=1$ and $y_2=4$.

$$\int_0^2x^2\,dx\approx\frac13\left[(0+4)+4(1)\right]=\frac83$$

Here this equals the exact value $\left[\dfrac{x^3}{3}\right]_0^2=\dfrac83$. The trapezoidal rule gave $3$.

Common mistake / Note: With four parts the multipliers are $1,4,2,4,1$. Start with $1$ at the first value and end with $1$ at the last value.

Exercise solutions of Chapter 10

Popular posts from this blog

Chapter 10 Numerical Methods MCQs and Short Questions – 12th Class Math Federal Board

Exercise 10.1 Solutions – 12th Class Math Federal Board (Root Finding by Iteration)

Exercise 10.2 Examples – 12th Class Math Federal Board (Trapezoidal and Simpson Rules)