1 Solution Of Nonlinear Equations

Numerical Method · Unit 1 · 8 hrs

Solution of Nonlinear Equations

Exam-focused notes for Solution of Nonlinear Equations (Numerical Method, CSC212): what the TU syllabus asks and how it has actually been tested, with 13 solved past questions from this unit.

Solution of Nonlinear Equations in short

Numerical methods replace exact analytical solutions with systematic arithmetic procedures that converge on an answer to a controlled accuracy. This chapter builds the error vocabulary needed to judge that accuracy, then develops the classical iterative methods used to solve a single nonlinear equation $f(x) = 0$ when no closed-form formula exists.

Solution of Nonlinear Equations: full notes

Errors in Numerical Calculations

Every computed result differs from the true value by some amount, and this difference is called error. The true error $E_t$ is the true (exact) value minus the approximate value, $$E_t = \text{true value} - \text{approximate value}.$$ Since the true value is rarely known in a numerical calculation, the approximate error $E_a$ is used instead: the difference between the current and the previous approximation, $$E_a = \text{present approximation} - \text{previous approximation}.$$ Both errors are more meaningfully expressed relative to the value they are measured against. The true relative error is $E_{rt} = E_t / (\text{true value})$ and the approximate relative error is $E_{ra} = E_a / (\text{present approximation})$; multiplying either by 100 gives a percentage error. In iterative methods, $|E_{ra}|$ is the practical stopping test: iteration continues until $|E_{ra}|$ falls below a preset tolerance.

Worked example. For $f(x) = 7e^{0.5x}$ at $x = 2$, the derivative can be approximated by the forward difference $f'(x) \approx \dfrac{f(x+h) - f(x)}{h}$. With $h = 0.3$, $$f'(2) \approx \frac{f(2.3) - f(2)}{0.3} = \frac{22.107 - 19.028}{0.3} = 10.2646.$$ The exact derivative is $f'(x) = 3.5e^{0.5x}$, so $f'(2) = 9.5140$. The true error is $$E_t = 9.5140 - 10.2646 = -0.7506,$$ and the true relative error is $E_{rt} = -0.7506/9.5140 = -0.0789$, or $-7.89%$. Repeating with $h = 0.15$ gives $f'(2) \approx 9.8799$; the approximate error is $E_a = 9.8799 - 10.2646 = -0.3847$, so $|E_{ra}| = 0.3847/9.8799 = 3.89%$. Halving $h$ roughly halved the error, as expected of a first-order forward-difference approximation.

Sources of Errors

Two error sources dominate numerical computation. Round-off error arises because a computer stores only a finite number of digits, so numbers such as $1/3 = 0.3333\ldots$ must be truncated to a fixed word length; the stored value and the exact value then differ by a small residual at every arithmetic step, and this residual can accumulate over many operations. Truncation error arises from replacing an infinite or exact mathematical process with a finite approximation. The classic example is the Maclaurin series for $e^x$, $$e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots,$$ which has infinitely many terms; keeping only the first three gives $e^x \approx 1 + x + x^2/2!$, and the truncation error is the sum of the terms dropped, $\dfrac{x^3}{3!} + \dfrac{x^4}{4!} + \cdots$. Reducing truncation error (using more terms, a smaller step size) generally increases the number of arithmetic operations and so increases accumulated round-off error, which is why numerical methods must balance the two rather than minimize either alone.

Propagation of Errors

When a calculation combines quantities that each carry their own uncertainty, the error propagates into the result. If $X = 1.50 \pm 0.05$ and $Y = 3.40 \pm 0.04$, the extreme values are $X \in [1.45, 1.55]$ and $Y \in [3.36, 3.44]$, so their sum satisfies $$1.45 + 3.36 \le X + Y \le 1.55 + 3.44 \quad\Rightarrow\quad 4.81 \le X + Y \le 4.99.$$ The bound width, $0.18$, is the sum of the two individual error widths ($0.10 + 0.08$), which is the general rule for addition: absolute errors add. For a general function $f(x_1, x_2, \ldots, x_n)$ of several uncertain inputs, first-order propagation gives $$\Delta f \approx \left|\frac{\partial f}{\partial x_1}\right|\Delta x_1 + \left|\frac{\partial f}{\partial x_2}\right|\Delta x_2 + \cdots + \left|\frac{\partial f}{\partial x_n}\right|\Delta x_n,$$ obtained by taking the total differential of $f$ and bounding each term by its absolute value.

Review of Taylor's Theorem

Taylor's theorem expresses the value of a function at $x+h$ in terms of the function and its derivatives at $x$: $$f(x+h) = f(x) + f'(x)h + \frac{f''(x)}{2!}h^2 + \frac{f'''(x)}{3!}h^3 + \cdots,$$ provided all the derivatives exist and are continuous on the interval concerned. Setting $x = 0$ gives the special case known as the Maclaurin series, $$f(h) = f(0) + f'(0)h + \frac{f''(0)}{2!}h^2 + \frac{f'''(0)}{3!}h^3 + \cdots.$$ Worked example. Estimate $e^{0.25}$ using the first five terms of the Maclaurin series for $e^x$, all of whose derivatives equal $e^x$, so every derivative at $0$ equals $1$: $$e^{0.25} \approx 1 + 0.25 + \frac{0.25^2}{2!} + \frac{0.25^3}{3!} + \frac{0.25^4}{4!} = 1 + 0.25 + 0.03125 + 0.002604 + 0.000163 = 1.28402.$$ The true value to five significant figures is $1.28403$, so four terms of the series already reproduce it almost exactly, illustrating how quickly a Taylor expansion converges for small $h$.

A closely related result, the Mean Value Theorem, states that if $f$ is continuous on $[a,b]$ and differentiable on $(a,b)$, there exists at least one point $c \in (a,b)$ such that $$f'(c) = \frac{f(b) - f(a)}{b-a},$$ that is, some point where the tangent is parallel to the secant joining the endpoints. It underlies the error and convergence analysis of every iterative method in this chapter.

Solving Non-linear Equations by Trial and Error method

An equation $f(x) = 0$ is non-linear if it is not of the form $ax+b=0$; this includes polynomial equations of degree two or higher and transcendental equations involving trigonometric, exponential or logarithmic terms (for example $2\sin x - x = 0$). Where no formula exists, the root must be located numerically. The crudest approach is the trial and error method: guess a value of $x$, evaluate $f(x)$, and if it is not sufficiently close to zero, refine the guess and repeat. It requires no theory beyond evaluating $f$, but converges unpredictably and gives no guarantee of finding a root at all. This motivates systematic iterative methods that use the shape of $f$ to choose each new guess: the bisection, Newton-Raphson, secant and fixed-point methods developed below.

Half-Interval method and Convergence

The bisection method (also called the half-interval method) starts from two points $a$ and $b$ that bracket a root, meaning $f(a)$ and $f(b)$ have opposite signs, so the Intermediate Value Theorem guarantees a root somewhere in $(a,b)$. At each step the midpoint $x_m = (a+b)/2$ is tested: if $f(a)\cdot f(x_m) < 0$ the root lies in $(a, x_m)$ and $b$ is replaced by $x_m$; otherwise it lies in $(x_m, b)$ and $a$ is replaced by $x_m$. The interval width is halved every iteration, so the method always converges, though slowly.

Worked example. Solve $f(x) = x^2 - 4\cos x = 0$ on $[1, 2]$, stopping when the relative change in $x_m$ is below $0.01$:

n$a$$b$$x_m$$f(a)$$f(b)$$f(x_m)$error
11.00002.00001.5000-1.16125.66461.9671-
21.00001.50001.2500-1.16121.96710.30120.2000
31.00001.25001.1250-1.16120.3012-0.45910.1111
41.12501.25001.1875-0.45910.3012-0.08580.0526
51.18751.25001.2188-0.08580.30120.10610.0256
61.18751.21881.2031-0.08580.10610.00970.0130
71.18751.20311.1953-0.08580.0097-0.03810.0065
81.19531.20311.1992-0.03810.0097-0.01420.0033

(error $= |x_m^{(n)} - x_m^{(n-1)}|/x_m^{(n)}$; the interval containing the root at each step is the one whose endpoints give opposite-sign $f$ values). After 8 iterations $x_m = 1.1992$ to four decimal places, with error already below $1%$.

Convergence. After $n$ iterations, the bracket width shrinks from $b-a$ to $(b-a)/2^n$, so the maximum possible error is $E_n = (b-a)/2^n$. Consequently $E_{n+1} = E_n/2$: the error is exactly halved every iteration, which is called linear convergence. Bisection is always convergent because it never leaves the bracket, but it is slow: to gain one more decimal digit of accuracy requires roughly $3.3$ further iterations regardless of how close the current estimate already is.

Bisection algorithm
1. Choose a, b with f(a)*f(b) < 0, and a tolerance e.
2. Repeat:
     xm = (a + b) / 2
     if f(a) * f(xm) < 0 then b = xm
     else a = xm
   until |(xm_new - xm_old) / xm_new| < e
3. Report xm as the root.

Newton's method and Convergence

The Newton-Raphson method uses the tangent line to $f$ at the current estimate $x_n$ to produce the next estimate: the tangent crosses the x-axis at $$x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}.$$ This also follows from truncating the Taylor expansion $f(x_n + h) = f(x_n) + f'(x_n)h$ after the linear term and solving $f(x_n) + f'(x_n)h = 0$ for the step $h = x_{n+1}-x_n$.

Worked example. Solve $x^2 + 4x - 9 = 0$ from $x_0 = 4$:

n$x_n$$f(x_n)$$f'(x_n)$$x_{n+1}$error
14.000023.000012.00002.08330.9200
22.08333.67368.16671.63350.2754
31.63350.20237.26701.60570.0173
41.60570.00087.21131.60560.0001

The root is $x = 1.6056$ (the positive root of $x^2+4x-9=0$, exactly $-2+\sqrt{13}$). Four iterations from a guess as far off as $x_0=4$ already give four correct decimals, in contrast to the eight bisection iterations above.

#include <stdio.h>
#include <math.h>

double f(double x) {
    return x * x + 4 * x - 9;
}

double fprime(double x) {
    return 2 * x + 4;
}

int main(void) {
    double x0 = 4.0, x1, tol = 0.0001;
    int iter = 0, maxIter = 50;

    do {
        x1 = x0 - f(x0) / fprime(x0);
        iter++;
        x0 = x1;
    } while (fabs(f(x1)) > tol && iter < maxIter);

    printf("Root = %.4f found in %d iterations\n", x1, iter);
    return 0;
}

Convergence and drawbacks. Writing $e_n = x_r - x_n$ for the error at step $n$ and expanding $f$ by Taylor's theorem about $x_n$ around the true root $x_r$ gives, after simplification, $$e_{n+1} = -\frac{f''(\xi)}{2f'(x_n)},e_n^2$$ for some $\xi$ between $x_n$ and $x_r$: the new error is proportional to the square of the old error, so Newton-Raphson has quadratic convergence, the fastest of the methods in this chapter, provided $f'(x_n) \ne 0$ near the root. It fails or behaves badly when the derivative is zero or very small at an iterate (division by zero or a wildly overshooting step), and it can oscillate indefinitely between two points if the initial guess lands near a local turning point of $f$.

Secant method and Convergence

The secant method approximates $f'(x_n)$ by a finite difference through the two most recent iterates instead of an exact derivative, so it needs two starting values $x_0, x_1$ but no bracketing and no derivative formula: $$x_{n+1} = x_n - \frac{f(x_n)(x_n - x_{n-1})}{f(x_n) - f(x_{n-1})}.$$

Worked example. Solve $f(x) = x^3 - x - 2 = 0$ from $x_0 = 1$, $x_1 = 2$:

n$x_{n-1}$$x_n$$f(x_{n-1})$$f(x_n)$$x_{n+1}$error
11.000002.00000-2.000004.000001.333330.50000
22.000001.333334.00000-0.962961.462690.08844
31.333331.46269-0.96296-0.333341.531170.04473
41.462691.53117-0.333340.058631.520930.00673
51.531171.520930.05863-0.002691.521380.00030

The root is $x = 1.52138$. Note the estimate is not monotone (it overshoots past the root at $n=1$ and corrects afterwards), unlike bisection which always tightens a bracket.

Convergence. A similar error analysis (using the Mean Value Theorem on the numerator and denominator) shows that the secant error obeys $e_{n+1} \approx C, e_n, e_{n-1}$ for a constant $C$ depending on $f''$ and $f'$. Assuming an order of convergence $p$ so that $e_{n+1} \propto e_n^{,p}$ leads to the equation $p^2 - p - 1 = 0$, whose positive root is $$p = \frac{1+\sqrt{5}}{2} \approx 1.618.$$ The secant method therefore converges faster than bisection (linear, $p=1$) but slower than Newton-Raphson (quadratic, $p=2$); this intermediate rate is called superlinear convergence. Its main practical advantage over Newton-Raphson is that it needs no derivative, at the cost of needing two starting points and a slightly slower rate.

Fixed point iteration and its convergence

The fixed-point iteration method rewrites $f(x) = 0$ algebraically as $x = g(x)$; any solution of the rewritten equation is also a root of the original equation, since the two are equivalent. Starting from a guess $x_0$, successive estimates are generated by $$x_{n+1} = g(x_n).$$ Geometrically, the root is the point where the curve $y = g(x)$ crosses the line $y = x$.

Worked example. Solve $x^2 - 6x + 8 = 0$ (roots $2$ and $4$). Adding $x$ to both sides gives the fixed-point form $x = x^2 - 5x + 8$, so $g(x) = x^2-5x+8$. From $x_0 = 1$, with tolerance $0.01$:

n$x_n$$x_{n+1}=g(x_n)$error
11.00004.00000.7500
24.00004.00000.0000

The iteration lands exactly on the root $x=4$ after a single non-trivial step and confirms itself as a fixed point immediately after ($g(4) = 16-20+8=4$).

Convergence. Subtracting $x_f = g(x_f)$ from $x_{n+1} = g(x_n)$ and applying the Mean Value Theorem gives $x_f - x_{n+1} = g'(\xi)(x_f - x_n)$ for some $\xi$ between $x_n$ and $x_f$, so the error obeys $e_{n+1} = g'(\xi),e_n$. The iteration therefore converges, linearly, only when $|g'(x)| < 1$ near the root; if $|g'(x)| \ge 1$ the iterates move away from the root regardless of how close the initial guess is. This is why the algebraic rearrangement chosen for $g(x)$ matters: not every rearrangement of the same equation converges.

Newton's method for calculating multiple roots

A polynomial of degree $n$ has $n$ roots (real or complex). Newton-Raphson finds one root at a time; after each root $x_r$ is found, the polynomial is deflated by dividing it by $(x - x_r)$ using synthetic division, giving a polynomial of degree $n-1$ whose remaining roots are exactly the remaining roots of the original polynomial. Repeating Newton-Raphson on the deflated polynomial, and deflating again, reduces the problem one degree at a time until a linear equation $ax+b=0$ remains, whose root is simply $-b/a$.

Worked example. Find all roots of $p(x) = x^4 - 2x^3 - 13x^2 + 38x - 24$.

Starting Newton-Raphson from $x_0 = 0.5$ on $p(x)$ itself:

n$x_n$$p(x_n)$$p'(x_n)$$x_{n+1}$error
10.50000-8.4375024.000000.851560.41284
20.85156-1.7768713.978490.978680.12988
30.97868-0.2191610.557090.999440.02077
40.99944-0.0056410.014651.000000.00056

so $x_r = 1$ is a root. Deflating $p(x)$ by $(x-1)$ gives $q_1(x) = x^3 - x^2 - 14x + 24$. Repeating Newton-Raphson on $q_1$ from $x_0 = 1$ converges in the same way to $x_r = 2$; deflating $q_1$ by $(x-2)$ gives $q_2(x) = x^2 + x - 12$. Newton-Raphson on $q_2$ from $x_0 = 2.5$ converges to $x_r = 3$ in four iterations; deflating by $(x-3)$ leaves the linear factor $x + 4$, whose root is $-4$. The four roots of $p(x)$ are therefore $1, 2, 3, -4$, which can be checked directly: $(x-1)(x-2)(x-3)(x+4) = x^4 - 2x^3 - 13x^2 + 38x - 24$.

Horner's method

Horner's method (also the basis of synthetic division) evaluates a polynomial $p(x) = a_nx^n + a_{n-1}x^{n-1} + \cdots + a_1x + a_0$ using only $n$ multiplications and $n$ additions, by nesting it as $$p(x) = a_0 + x\big(a_1 + x\big(a_2 + x(\cdots + x(a_{n-1}+xa_n)\cdots)\big)\big).$$ Working from the highest coefficient down, a sequence $b_n = a_n$, $b_{k-1} = a_{k-1} + b_k,x$ is computed; the final value $b_0$ equals $p(x)$, and by the Remainder Theorem it also equals the remainder of dividing $p(x)$ by $(x-c)$ when evaluating at $x=c$. The intermediate $b$ values, read in order, are exactly the coefficients of the deflated (quotient) polynomial used in the previous section.

Worked example. Evaluate $p(x) = 3x^3 - 4x^2 + 5x - 6$ at $x = 2$: $$ \begin{aligned} b_3 &= 3 \ b_2 &= -4 + 3(2) = 2 \ b_1 &= 5 + 2(2) = 9 \ b_0 &= -6 + 9(2) = 12. \end{aligned} $$ So $p(2) = 12$, obtained with only 3 multiplications instead of the 6 that direct substitution of powers would need.

#include <stdio.h>

double hornerEval(double coeff[], int n, double x) {
    double result = coeff[0];
    for (int i = 1; i <= n; i++) {
        result = result * x + coeff[i];
    }
    return result;
}

int main(void) {
    double coeff[] = {3, -4, 5, -6};
    int degree = 3;
    double x = 2.0;

    printf("p(%.1f) = %.4f\n", x, hornerEval(coeff, degree, x));
    return 0;
}

The table below summarises the four iterative root-finding methods developed in this chapter.

MethodNeeds derivative?Bracketing required?Order of convergenceCost per iteration
BisectionNoYes1 (linear)1 function evaluation
Fixed-pointNoNo1 (linear, needs $\lvert g'\rvert<1$)1 function evaluation
SecantNoNo$\approx 1.618$ (superlinear)1 function evaluation
Newton-RaphsonYesNo2 (quadratic)1 function + 1 derivative evaluation

What this unit covers

  • Errors in Numerical Calculations
  • Sources of Errors
  • Propagation of Errors
  • Review of Taylor's Theorem
  • Solving Non-linear Equations by Trial and Error method
  • Half-Interval method and Convergence
  • Newton's method and Convergence
  • Secant method and Convergence
  • Fixed point iteration and its convergence
  • Newton's method for calculating multiple roots
  • Horner's method

Newton's method and Convergence

2081 · 10 marks

What are inherent errors? Derive the Newton Raphson method for solving non-linear equation and using this method solve the following equation up to 3 decimal places: $x^2 - 5x + 6 = 0$ [10]

Show solved answer

Inherent Errors and Newton-Raphson Method

Part 1: Inherent Errors (2 marks)

Inherent errors are errors that already exist in a problem before any numerical computation is carried out. They are caused by the data or by the mathematical model, not by the numerical technique used.

Main sources:

  • Data errors: Values obtained from physical measurements or observation carry uncertainty.
  • Modelling / simplifying assumptions: Approximating a real system by a simplified mathematical model introduces error.
  • Errors in empirical constants: Constants determined experimentally are not exact.

Such errors cannot be removed by using a better numerical method; they can only be controlled so that they are not amplified.


Part 2: Derivation of Newton-Raphson Method (4 marks)

Let $f(x)=0$ be the equation whose root is required, and let $x_n$ be an approximate root.

Expand $f(x_n+h)$ by Taylor's series:

$$f(x_n+h)=f(x_n)+h,f'(x_n)+\frac{h^2}{2!}f''(x_n)+\cdots$$

Since $h$ is small, neglect second and higher order terms:

$$f(x_n+h)\approx f(x_n)+h,f'(x_n)$$

If $x_n+h$ is the exact root, then $f(x_n+h)=0$:

$$0=f(x_n)+h,f'(x_n)\quad\Rightarrow\quad h=-\frac{f(x_n)}{f'(x_n)}$$

Hence the improved approximation $x_{n+1}=x_n+h$ gives:

$$\boxed{x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)},\qquad f'(x_n)\neq 0}$$


Part 3: Solve $x^2-5x+6=0$ to 3 Decimal Places (4 marks)

$$f(x)=x^2-5x+6,\qquad f'(x)=2x-5$$

Iteration formula:

$$x_{n+1}=x_n-\frac{x_n^2-5x_n+6}{2x_n-5}$$

(Exact roots: $(x-2)(x-3)=0 \Rightarrow x=2,,3$.)

Root near $x=3$, take $x_0=4$

Iteration 1: $$f(4)=16-20+6=2,\quad f'(4)=3$$ $$x_1=4-\tfrac{2}{3}=3.3333$$

Iteration 2: $$f(3.3333)=11.1109-16.6665+6=0.4444,\quad f'(3.3333)=1.6666$$ $$x_2=3.3333-\tfrac{0.4444}{1.6666}=3.0667$$

Iteration 3: $$f(3.0667)=9.4046-15.3335+6=0.0711,\quad f'(3.0667)=1.1334$$ $$x_3=3.0667-\tfrac{0.0711}{1.1334}=3.0040$$

Iteration 4: $$f(3.0040)=9.0240-15.0200+6=0.0040,\quad f'(3.0040)=1.0080$$ $$x_4=3.0040-\tfrac{0.0040}{1.0080}=3.0000$$

$$\boxed{x=3.000}$$

Root near $x=2$, take $x_0=1$

Iteration 1: $$f(1)=1-5+6=2,\quad f'(1)=-3$$ $$x_1=1-\tfrac{2}{-3}=1.6667$$

Iteration 2: $$f(1.6667)=2.7779-8.3335+6=0.4444,\quad f'(1.6667)=-1.6666$$ $$x_2=1.6667-\tfrac{0.4444}{-1.6666}=1.9334$$

Iteration 3: $$f(1.9334)=3.7380-9.6670+6=0.0710,\quad f'(1.9334)=-1.1332$$ $$x_3=1.9334-\tfrac{0.0710}{-1.1332}=1.9961$$

Iteration 4: $$f(1.9961)=3.9844-9.9805+6=0.0039,\quad f'(1.9961)=-1.0078$$ $$x_4=1.9961-\tfrac{0.0039}{-1.0078}=2.0000$$

$$\boxed{x=2.000}$$

Final Result

The roots of $x^2-5x+6=0$ correct to 3 decimal places are:

$$x=2.000 \quad\text{and}\quad x=3.000$$

Open this answer on its own page →

2077 · 10 marks

Derive the formula for Newton Raphson Method. Solve the equation using Newton Raphson method. Assume error precision is 0.01. Discuss drawbacks of the Newton Raphson method. $x^2 + 4x - 9 = 0$ [10]

  • Equation: $f(x) = x^2 + 4x - 9 = 0$ - Error precision: $E = 0.01$ - Initial guess: not specified in the problem, so I take $x0 = 4$ The exact positive root is $x = -2 + \sqrt{13} = 1.60555...$ --- Expand $f(x)$ by Taylor series about $xn$: $$f(xn + h) = f(xn) + h f'(xn) + \frac{h^2}{2!}f''(xn) ...
Open this answer on its own page →

2075 · 5 marks

Calculate a real negative root of following equation using Newton’s method for polynomial. $x^4 + 2x^3 + 3x^2 + 4x = 5$. [5]

Equation: $$x^4 + 2x^3 + 3x^2 + 4x = 5$$ Rearranged: $$f(x) = x^4 + 2x^3 + 3x^2 + 4x - 5 = 0$$ $$x{n+1} = xn - \frac{f(xn)}{f'(xn)}, \qquad f'(x) = 4x^3 + 6x^2 + 6x + 4$$ $$f(-1) = 1 - 2 + 3 - 4 - 5 = -7 ;(<0)$$ $$f(-2) = 16 - 16 + 12 - 8 - 5 = -1 ;(<0)$$ $$f(-3) = 81 - 54 + 27 - 12 - 5 = 37 ;...

Open this answer on its own page →

Secant method and Convergence

2080 · 10 marks

How secant methods differs from Newton Raphson method? Derive the formula for Secant Method. Solve the equation using Secant method. Assume error precision as 0.01. Discuss the drawbacks of the Newton Raphson method.cos⁡x+2sin⁡x−x2=0\cos x + 2\sin x - x^2 = 0cosx+2sinx−x2=0[10]

  • Equation: $f(x) = \cos x + 2\sin x - x^2 = 0$ - Error precision (tolerance): $E = 0.01$ - Initial guesses: not specified in question. I choose $x0 = 1$, $x1 = 2$ (bracketing the root, angles in radians). Feature Newton-Raphson Secant --------- Requires $f(x)$ and $f'(x)$ $f(x)$ only Initial gue...
Open this answer on its own page →

2079 · 10 marks

How secant method can approximate the root of a non-linear equation? Explain with necessary derivation. Estimate a real root of following equation using secant method. Assume error precision of 0.01. $x^3 + 2x - \cos(x) = 4$ [10]

  • Equation: $x^3 + 2x - \cos(x) = 4$, i.e. $f(x) = x^3 + 2x - \cos(x) - 4 = 0$ - Error precision: $E = 0.01$ - Method: Secant method - Initial guesses: not specified (to be chosen from sign change). All angles in radians. Newton-Raphson formula: $$x{n+1} = xn - \frac{f(xn)}{f'(xn)}$$ The secant m...
Open this answer on its own page →

2075 · 10 marks

What is non-linear equation? Derive the required expression to calculate the root of non-linear equation using secant method. Using this expression find a root of following equation.

$$x^2 + \cos(x) - e^{-x} - 2 = 0$$

[10]

Show solved answer

Non-Linear Equations and the Secant Method

1. Non-Linear Equation

A non-linear equation is an equation $f(x)=0$ in which the unknown appears in a degree higher than one, or inside transcendental functions (trigonometric, exponential, logarithmic). Its graph is not a straight line, and it generally cannot be solved by direct algebraic manipulation, so iterative numerical methods are used.

Examples: $x^2+\cos x-e^{-x}-2=0$, $x^3-4x+1=0$, $e^x-3x=0$.

2. Derivation of the Secant Method

Start from the Newton-Raphson formula:

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

The Secant method replaces the analytic derivative with a finite-difference approximation using two known points:

$$f'(x_n)\approx\frac{f(x_n)-f(x_{n-1})}{x_n-x_{n-1}}$$

Substituting:

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

This needs two initial guesses $x_0,,x_1$.

3. Numerical Solution

$$f(x)=x^2+\cos x-e^{-x}-2$$

(radian mode)

Bracketing:

$x$$f(x)$
1$1+0.5403-0.3679-2=-0.8276$
2$4-0.4161-0.1353-2=+1.4486$

Root lies in $(1,2)$. Take $x_0=1,\ x_1=2$.

Iteration 1

$$x_2=2-\frac{1.4486(2-1)}{1.4486-(-0.8276)}=2-\frac{1.4486}{2.2762}=2-0.6364=1.3636$$

$$f(1.3636)=1.8594+0.2050-0.2557-2$$

Check $\cos(1.3636)=0.2064$ (radians), $e^{-1.3636}=0.2557$, $(1.3636)^2=1.8594$: $$f(1.3636)=1.8594+0.2064-0.2557-2=-0.1899$$

Iteration 2

$$x_3=1.3636-\frac{(-0.1899)(1.3636-2)}{-0.1899-1.4486}$$ $$=1.3636-\frac{(-0.1899)(-0.6364)}{-1.6385}=1.3636-\frac{0.1209}{-1.6385}$$ $$=1.3636+0.0738=1.4374$$

$$f(1.4374)=2.0661+\cos(1.4374)-e^{-1.4374}-2$$ $\cos(1.4374)=0.1330,\ e^{-1.4374}=0.2375$ $$=2.0661+0.1330-0.2375-2=-0.0384$$

Iteration 3

$$x_4=1.4374-\frac{(-0.0384)(1.4374-1.3636)}{-0.0384-(-0.1899)}$$ $$=1.4374-\frac{(-0.0384)(0.0738)}{0.1515}=1.4374-\frac{-0.002834}{0.1515}$$ $$=1.4374+0.0187=1.4561$$

$$f(1.4561)=2.1202+\cos(1.4561)-e^{-1.4561}-2$$ $\cos(1.4561)=0.1145,\ e^{-1.4561}=0.2331$ $$=2.1202+0.1145-0.2331-2=+0.0016$$

Iteration 4

$$x_5=1.4561-\frac{(0.0016)(1.4561-1.4374)}{0.0016-(-0.0384)}$$ $$=1.4561-\frac{0.0016\times0.0187}{0.0400}=1.4561-0.00075=1.4553$$

$f(1.4553)\approx 0.0000$.

Result

$$\boxed{x\approx 1.4553}$$

Watch the trigonometry: $\cos(1.3636) \approx 0.2064$, not $0.2190$, so $f(1.3636) \approx -0.19$ rather than $-0.1773$. The slip does not move the converged root, which stays at $\approx 1.455$.

Open this answer on its own page →

Half-Interval method and Convergence

2080 · 5 marks

Define the terms approximate error and relative approximate error? Discuss the working of Half Interval method for finding the roots of non-linear equation. [5]

--- Approximate Error is the difference between the current approximation and the previous approximation of a root. It gives an estimate of how much the solution has changed between two successive iterations. $$Ea = x{new} - x{old}$$ Since the true value is often unknown in numerical methods, thi...

Open this answer on its own page →

2079 · 5 marks

Calculate a real root of the following function using bisection method correct upto 3 significant figures. $x^2 - e^x = 3$ [5]

Equation: $x^2 - e^x = 3$ Rearranged as: $f(x) = x^2 - e^x - 3 = 0$ Required accuracy: 3 significant figures. --- $x$ $f(x) = x^2 - e^x - 3$ Sign --------- $-1$ $1 - 0.3679 - 3 = -2.368$ $-$ $-2$ $4 - 0.1353 - 3 = +0.865$ $+$ Sign change between $-2$ and $-1$, so a root lies in $[-2, -1]$. Let

Open this answer on its own page →

2078 · 5 marks

How the half-interval method can be estimate a root of a non-linear equation? Find a real root of the following equation using the half-interval method to correct up to two decimal places. $x^2 - e^{-x} - x = 1$ [5]

  • Equation: $x^2 - e^{-x} - x = 1$ - Rearranged: $f(x) = x^2 - e^{-x} - x - 1 = 0$ - Required accuracy: two decimal places The half-interval (bisection) method is based on the Intermediate Value Theorem: if $f(x)$ is continuous on $[a,b]$ and $f(a)\cdot f(b)<0$, then at least one real root lies i...
Open this answer on its own page →

Fixed point iteration and its convergence

2079 · 5 marks

What is fixed point iteration method? How can it converge to the root of a non-linear equation? Also explain the diverging cases with suitable examples. [5]

In the Fixed Point Iteration Method, we rearrange the non-linear equation f(x) = 0 such that x is isolated on the left-hand side of the equation. The rearranged form is expressed as: $$x = g(x) \quad \cdots (1)$$ Since f(x) = 0 and x = g(x) are equivalent forms, the root of f(x) = 0 is also the r...

Open this answer on its own page →

2078 · 5 marks

Calculate the real root of the given equation using fixed point iteration correct up to 3 significant figures. $2x^3 - 2x = 5$. [5]

  • Equation: $2x^3 - 2x = 5$, i.e. $f(x) = 2x^3 - 2x - 5 = 0$ - Method: Fixed point iteration - Required accuracy: 3 significant figures No initial guess given; must be determined by root location. Rearrange to $x = g(x)$: $$2x^3 = 5 + 2x \implies x = \left(\frac{5 + 2x}{2}\right)^{1/3} = g(x)$$ C...
Open this answer on its own page →

Horner's method

2078 · 10 marks

How can Horner’s rule be used to evaluate the f(x) and f(x) of a polynomial at a given point? Explain. Write an algorithm and program to calculate a real root of a polynomial using Horner’s rule.[10]

Horner's rule is an efficient scheme for evaluating a polynomial and its derivative at a point by rewriting the polynomial in nested form. It is closely related to synthetic division and the Remainder Theorem. For a polynomial of degree $n$: $$f(x) = a0 x^n + a1 x^{n-1} + a2 x^{n-2} + \cdots + a{...

Open this answer on its own page →

2077 · 5 marks

Define the terms true error and relative error? Use Horner' method to evaluate polynomial at x = 3 and write down its algorithm. $2x^3 - 3x^2 + 5x - 2$ [5]

Show solved answer

True Error and Relative Error + Horner's Method

Given Data

  • Polynomial: $P(x) = 2x^3 - 3x^2 + 5x - 2$
  • Evaluation point: $x = 3$
  • Coefficients: $a_3 = 2,\ a_2 = -3,\ a_1 = 5,\ a_0 = -2$

Part 1: Definitions

True Error

True error is the difference between the exact (true) value of a quantity and its approximate (computed) value.

$$E_t = \text{True Value} - \text{Approximate Value}$$

It measures the actual (absolute) magnitude of the discrepancy in a numerical computation.

Relative Error

Relative error is the ratio of the true error to the true value, giving the error relative to the size of the exact quantity.

$$E_r = \frac{E_t}{\text{True Value}} = \frac{\text{True Value} - \text{Approximate Value}}{\text{True Value}}$$

Often expressed as a percentage:

$$E_r% = \left|\frac{\text{True Value} - \text{Approximate Value}}{\text{True Value}}\right| \times 100%$$


Part 2: Horner's Method

Concept

Horner's method reduces the number of multiplications by nesting coefficients:

$$P(x) = a_nx^n + \cdots + a_1x + a_0 = \big(\cdots((a_n x + a_{n-1})x + a_{n-2})\cdots\big)x + a_0$$

For our polynomial:

$$P(x) = ((2x - 3)x + 5)x - 2$$

Step-by-Step Evaluation at $x = 3$

StepOperationResult
Start$b_3 = a_3$$2$
1$b_2 = b_3 \cdot 3 + a_2 = 2(3) - 3$$3$
2$b_1 = b_2 \cdot 3 + a_1 = 3(3) + 5$$14$
3$b_0 = b_1 \cdot 3 + a_0 = 14(3) - 2$$40$

$$\boxed{P(3) = 40}$$

Verification (Direct Substitution)

$$P(3) = 2(27) - 3(9) + 5(3) - 2 = 54 - 27 + 15 - 2 = 40 \checkmark$$


Algorithm for Horner's Method

Algorithm: Horner's Method for Polynomial Evaluation

Input  : Degree n, coefficients a[n], a[n-1], ..., a[0], value x
Output : P(x)

Step 1: Start
Step 2: Read n, coefficients a[n] down to a[0], and value x
Step 3: Set result = a[n]              // leading coefficient
Step 4: For i = n-1 down to 0 do
            result = result * x + a[i]
        End For
Step 5: Print result as P(x)
Step 6: Stop

Therefore, $P(3) = 40$.

Open this answer on its own page →