Sample Answer
Applications of Numerical Methods in MATLAB for Problem Solving
Introduction
Numerical methods are essential tools in engineering and applied sciences, especially when analytical solutions are either difficult or impossible to obtain. MATLAB provides a powerful environment for implementing these methods efficiently. This report explores five key numerical techniques: the Bisection Method, Newton-Raphson Method, Jacobi Method, Power Method, and numerical integration using the Composite Trapezium and Simpson’s Rules. Each section outlines how these methods can be implemented in MATLAB, discusses their underlying principles, and analyses their role in improving computational accuracy and efficiency.
The Bisection Method
The Bisection Method is a simple yet reliable technique for finding roots of nonlinear equations. It operates by repeatedly halving an interval in which a function changes sign, thus ensuring that a root lies within it. In MATLAB, the algorithm begins with two initial guesses, a and b, such that the function values at these points have opposite signs. The midpoint of the interval is then computed, and depending on the sign of the function at that midpoint, one half of the interval is selected for the next iteration.
For example, consider the equation f(x)=x3−x−2=0f(x) = x^3 - x - 2 = 0f(x)=x3−x−2=0 within the interval [1, 2]. In MATLAB, this function is coded as f = @(x) x.^3 - x - 2. The iterative loop continues until the difference between a and b becomes smaller than a predefined tolerance, usually 10−610^{-6}10−6. The final midpoint is taken as the approximate root. This method guarantees convergence, although it can be slower than other methods because of its reliance on interval halving rather than gradient-based improvements.
In testing, the MATLAB code found a root near x = 1.521, matching the analytical solution. This demonstrates that the Bisection Method is particularly suitable for problems where robustness is more important than speed.
The Newton-Raphson Method
The Newton-Raphson Method is a faster alternative that uses calculus to find roots more efficiently. It relies on an initial guess x0 and repeatedly refines it using the formula
xn+1=xn−f(xn)f′(xn)x_{n+1} = x_n - frac{f(x_n)}{f`(x_n)}xn+1=xn−f′(xn)f(xn).
In MATLAB, this is implemented using an anonymous function for both the function and its derivative. For the same example, f(x)=x3−x−2f(x) = x^3 - x - 2f(x)=x3−x−2, the derivative is f′(x)=3x2−1f`(x) = 3x^2 - 1f′(x)=3x2−1. Starting from x0 = 1.5, the code iterates until the change between successive approximations is less than a small tolerance.
The Newton-Raphson method converged to the same root x = 1.521, but within fewer iterations than the Bisection Method. However, this efficiency comes with a risk: if the initial guess is poorly chosen or the derivative approaches zero, the method can diverge. Thus, it is best suited for smooth functions with readily available derivatives and reasonable initial estimates.
The Jacobi Method
The Jacobi Method is used to solve systems of linear equations in the form Ax=bA x = bAx=b. It works by iteratively updating each variable based on the values of the others from the previous iteration. This method is particularly useful for large, sparse systems that are diagonally dominant.
In MATLAB, the system is represented by a coefficient matrix A and a constant vector b. Each element of the solution vector is recalculated in every iteration until the difference between successive iterations becomes negligible. For instance, using a 4x4 diagonally dominant system, the Jacobi method quickly converged to the correct set of values within a few hundred iterations, showing stable performance.
While slower than direct methods such as Gaussian elimination, the Jacobi Method is preferred in computational simulations where matrix sparsity and parallelisation are important, such as in structural analysis or fluid dynamics.