Numerical Method Concepts Quiz
Topic: Solution of Nonlinear Equations
Solution of Nonlinear Equations (10 Hours)
Nonlinear equations are equations that involve nonlinear terms, such as variables raised to a power other than one, trigonometric functions, exponential functions, and more. Solving these equations is fundamental in numerical methods, as they arise in many engineering, physics, and mathematical applications.
1. Introduction to Nonlinear Equations
- A nonlinear equation is an equation of the form , where is a nonlinear function.
- Examples include:
- These equations generally cannot be solved analytically and require numerical methods.
2. Types of Equations
- Algebraic Equations: Polynomial equations, e.g., .
- Transcendental Equations: Equations involving trigonometric, exponential, or logarithmic functions, e.g., .
3. Errors in Computing
Errors arise due to approximations in numerical methods. Common types include:
- Absolute Error:
- Relative Error:
- Truncation Error: Errors due to approximating a mathematical process.
4. Numerical Methods for Solving Nonlinear Equations
4.1 The Bisection Method
- Principle: The method divides an interval into halves and repeatedly checks where the root lies. It requires .
- Formula:
- Advantages: Simple and reliable.
- Disadvantages: Slow convergence.
Example: Solve using the Bisection Method on .
- , , .
- Midpoint: , .
- Update interval to .
- Repeat until desired accuracy.
Practice Question: Solve on using the Bisection Method.
4.2 The Method of False Position (Regula Falsi)
- Principle: Similar to the Bisection Method but uses a linear approximation between points.
- Formula:
- Advantages: Faster than Bisection.
- Disadvantages: Can stagnate.
Example: Solve on .
- , , .
- .
- Update interval and repeat.
Practice Question: Solve on using the Method of False Position.
4.3 Newton-Raphson Method
- Principle: Uses the tangent line at a point to approximate the root.
- Formula:
- Advantages: Very fast convergence near the root.
- Disadvantages: Requires derivative and may diverge.
Example: Solve with .
- , .
- .
- Repeat until desired accuracy.
Practice Question: Solve using Newton-Raphson with .
4.4 Fixed-Point Iteration
- Principle: Rewrites the equation as and iterates.
- Formula:
- Convergence Criterion:
Example: Solve by rewriting as .
- , .
- .
- Repeat.
Practice Question: Solve by Fixed-Point Iteration.
4.5 Solution of a System of Nonlinear Equations
- Uses extensions of methods like Newton-Raphson.
- Example: Solve: using an iterative approach.
Summary
- Bisection Method: Reliable, slower.
- Method of False Position: Faster, may stagnate.
- Newton-Raphson: Fast, requires derivative.
- Fixed-Point Iteration: Simple, depends on .
- System of Equations: Extension of Newton-Raphson.
Practice Problems
- Solve using Newton-Raphson with .
- Solve on using the Method of False Position.
- Solve the system: using a numerical method.
Topic: Interpolation and Approximation
Interpolation and Approximation (10 Hours)
Interpolation and approximation are methods used to estimate values of a function based on known data points. These techniques are crucial in numerical analysis for solving engineering and scientific problems where analytical solutions are impractical.
1. Introduction
- Interpolation: Estimation of function values at intermediate points using known data points.
- Approximation: Finding a function that closely represents a given set of data points, even if the function doesn't pass through them exactly.
Applications
- Predicting missing data points.
- Smoothing noisy data.
- Constructing simpler models for complex functions.
2. Errors in Polynomial Interpolation
The error in interpolation is given by:
where is the interpolating polynomial, is a point in , and is the degree of the polynomial.
Key Points
- Higher-degree polynomials may lead to oscillations (Runge's phenomenon).
- The accuracy depends on the spacing of data points and the behavior of .
Example: Given at , find the interpolation error at using a second-degree polynomial.
Solution:
- Derive .
- Compute on : .
- Compute .
Practice Question: Compute the interpolation error for at using points .
3. Lagrange's Polynomial
Lagrange's interpolation formula is:
Example:
Given , , , find .
Solution:
- Construct the Lagrange polynomial:
- Substitute , , , and simplify.
- Evaluate .
Practice Question: Use Lagrange's interpolation to find for , , .
4. Newton’s Interpolation
4.1 Using Divided Differences
Newton's formula is:
where divided differences are:
Example: Given , find using Newton’s divided differences.
Solution:
- Compute divided differences:
- Polynomial: .
- Evaluate .
Practice Question: Use Newton’s divided differences to interpolate for , , .
4.2 Using Forward Differences
Newton's forward interpolation formula:
where and is the step size.
Practice Question: Use Newton’s forward differences to estimate given , and .
5. Cubic Spline Interpolation
Cubic splines construct piecewise cubic polynomials that are smooth and continuous up to the second derivative.
Example:
Given , , construct the cubic spline.
Solution:
- Solve for coefficients of each cubic polynomial:
- Use continuity and smoothness conditions.
Practice Question: Construct a cubic spline for and .
6. Least Squares Method
6.1 Linear Data
Fits a straight line to minimize:
Example: Fit to .
Solution:
- Compute normal equations:
- Solve for .
Practice Question: Fit a line to .
6.2 Nonlinear Data
Transforms nonlinear models (e.g., exponential ) to linear forms:
Practice Question: Fit to .
Topic: Numerical Differentiation and Integration
Numerical Differentiation and Integration (5 Hours)
Numerical differentiation and integration involve approximating derivatives and integrals when analytical methods are impractical or impossible. These techniques are widely used in engineering, physics, and other scientific disciplines.
1. Introduction to Numerical Differentiation
Numerical differentiation estimates derivatives using values of a function at discrete points. It is based on finite differences:
- Forward Difference:
- Backward Difference:
- Central Difference:
Example:
Given at , with , find using forward, backward, and central differences.
Solution:
- , , .
- Forward Difference:
- Backward Difference:
- Central Difference:
Practice Question: Use forward, backward, and central differences to find for at , .
2. Newton's Differentiation Formulas
Newton’s forward and backward difference formulas extend numerical differentiation to tabular data.
Newton’s Forward Difference Formula:
Newton’s Backward Difference Formula:
Example:
Given the table:
| 1 | 2 | 3 | |
|---|---|---|---|
| 1 | 4 | 9 |
Find at using Newton’s forward formula.
Solution:
- Compute forward differences:
- .
Practice Question: Use Newton’s forward difference formula to find for the table:
| 0.5 | 1.0 | 1.5 | |
|---|---|---|---|
| 0.25 | 1.00 | 2.25 |
3. Numerical Integration
Numerical integration approximates the value of definite integrals when the function cannot be integrated analytically.
3.1 Trapezoidal Rule
The integral is approximated by dividing the area under the curve into trapezoids:
where .
Example: Approximate using the trapezoidal rule with .
Solution:
- , .
- , , .
- Apply the formula:
Practice Question: Approximate using the trapezoidal rule with .
3.2 Simpson’s 1/3 Rule
The integral is approximated using parabolic segments:
Example: Approximate using Simpson’s 1/3 rule with .
Solution:
- , .
- , , .
- Apply the formula:
Practice Question: Approximate using Simpson’s 1/3 rule with .
3.3 Simpson’s 3/8 Rule
The rule is:
Practice Question: Use Simpson’s 3/8 rule to approximate with .
3.4 Romberg Integration
Romberg integration refines the trapezoidal rule using Richardson extrapolation.
Example: Approximate using Romberg integration.
Practice Question: Use Romberg integration to approximate .
4. Numerical Double Integration
For double integrals:
numerical integration can be applied iteratively.
Example:
Approximate:
using the trapezoidal rule.
Solution:
- Outer integral: , where .
- Compute using the trapezoidal rule: and integrate with respect to .
Practice Question: Approximate:
using the trapezoidal rule.
Topic: Solution of Linear Algebraic Equations
Solution of Linear Algebraic Equations (10 Hours)
Linear algebraic equations are equations involving linear combinations of variables. Numerical methods are often employed to solve systems of linear equations when analytical methods become infeasible for large systems. This module covers various methods for solving linear systems.
1. Review of the Existence of Solutions and Properties of Matrices
Existence of Solutions
- A system of linear equations has:
- Unique solution: When , is invertible.
- Infinite solutions: When is singular, and the system is consistent.
- No solution: When the system is inconsistent.
Properties of Matrices
- Square matrix: has the same number of rows and columns.
- Symmetric matrix: .
- Diagonal matrix: Only diagonal elements are nonzero.
- Singular matrix: .
Consistency of a Linear System
A system is consistent if there exists at least one solution. To check:
- Compute the rank of (coefficient matrix) and augmented matrix .
- If , the system is consistent.
Example: Solve the system using rank:
Solution:
- Coefficient matrix:
- Augmented matrix:
- Rank:
Practice Question: Check the consistency of the system:
2. Gaussian Elimination Method
Gaussian elimination transforms into an upper triangular form for back substitution.
Steps:
- Augment with .
- Use row operations to create zeros below the diagonal.
- Solve the triangular system using back substitution.
Example: Solve:
Solution:
- Augmented matrix:
- Eliminate from rows 2 and 3:
- Eliminate from row 3:
- Back substitution:
Practice Question: Solve using Gaussian elimination:
3. Gauss-Jordan Method
Gauss-Jordan elimination reduces the matrix to reduced row echelon form (RREF).
Steps:
- Augment with .
- Use row operations to create zeros above and below each pivot.
Example: Solve:
Solution:
- Augment with .
- Transform to RREF:
- Solution: .
Practice Question: Solve using Gauss-Jordan:
4. Inverse of a Matrix Using Gaussian Elimination
To find , augment with the identity matrix and use Gaussian elimination to reduce to the identity matrix.
Example: Find the inverse of:
Solution:
- Augment with identity:
- Reduce to identity:
Practice Question: Find the inverse of:
5. Method of Factorization
LU Decomposition
Decompose into (lower triangular) and (upper triangular) matrices.
Example:
Factorize:
Solution:
- ( L = \begin{bmatrix} 1 & 0 \ 2 & 1 \end{bmatrix}, \quad U = \begin{bmatrix} 2 & 3 \ 0 & 1 \end{bmatrix}. ]
Practice Question: Factorize:
6. Iterative Methods
Jacobi Iteration
Gauss-Seidel Iteration
Example: Solve:
Practice Question: Solve:
7. Power Method
Find the largest eigenvalue and its eigenvector.
Example: Find the largest eigenvalue of:
Practice Question: Find the largest eigenvalue of:
Topic: Solution of Ordinary Differential Equations
Solution of Ordinary Differential Equations (ODEs) - 7 Hours
Ordinary Differential Equations (ODEs) are equations involving derivatives of a function with respect to a single variable. Numerical methods for ODEs are used when exact solutions are difficult or impossible to obtain.
1. Introduction to Differential Equations
- General Form of ODE: where is a given function.
- Order of ODE: The order is determined by the highest derivative present.
- Initial Value Problem (IVP): Solve given .
2. Taylor Series Method
The Taylor Series method expands around :
Example:
Solve , , find using the Taylor series up to the second term.
Solution:
- .
- Using :
Practice Question: Solve , , find using the Taylor series up to the third term.
3. Picard's Method
Picard's iteration provides successive approximations to the solution:
Example:
Solve , for .
Solution:
- First approximation:
- Second approximation: Substitute into the integral.
Practice Question: Solve , for .
4. Euler's Method
Euler's method approximates using:
where is the step size.
Example:
Solve , find using .
Solution:
- .
- .
Practice Question: Solve , for using .
5. Heun's Method
Heun's method improves Euler's method by averaging the slopes:
where .
Example:
Solve , find .
Solution:
- Predictor (Euler’s step):
- Corrector:
Practice Question: Solve , for using Heun's method.
6. Runge-Kutta Methods
Second-Order Runge-Kutta (RK2):
Fourth-Order Runge-Kutta (RK4):
where:
Example: Solve , find using RK4 with .
Solution:
- ,
Practice Question: Solve , for using RK4.
7. Solutions of Higher Order Equations
Higher-order ODEs can be reduced to a system of first-order equations:
Example: Solve , , for .
Solution:
- Convert to first-order:
- Use RK4 or other methods to solve.
Practice Question: Solve , , for .
8. Boundary Value Problems (BVPs)
In BVPs, conditions are specified at multiple points. Common methods include:
- Shooting Method: Convert the BVP to an IVP and iterate to match boundary conditions.
Algorithm for Shooting Method:
- Guess an initial slope . 2
. Solve the IVP using numerical methods. 3. Adjust the guess until the boundary condition is satisfied.
Example: Solve , .
Practice Question: Solve , , using the shooting method.
Topic: Solution of Partial Differential Equations
Solution of Partial Differential Equations (PDEs) - 5 Hours
Partial Differential Equations (PDEs) involve multiple independent variables and their partial derivatives. These equations are fundamental in modeling physical phenomena such as heat conduction, fluid dynamics, and wave propagation.
1. Introduction to Partial Differential Equations
General Form of PDEs
A PDE is expressed as:
where is the dependent variable.
Types of PDEs
- Elliptic PDEs: (e.g., Laplace's equation).
- Parabolic PDEs: (e.g., Heat equation).
- Hyperbolic PDEs: (e.g., Wave equation).
2. Deriving Difference Equations
Finite Difference Approximations
To solve PDEs numerically, the domain is discretized, and derivatives are approximated using finite differences.
-
Forward Difference:
-
Backward Difference:
-
Central Difference:
-
Second Derivative:
Example:
Discretize .
Solution:
- Divide the domain into a grid with spacing in both and .
- Replace derivatives with finite differences:
- Combine terms:
Practice Question: Derive the finite difference approximation for .
3. Laplace's Equation
Form:
- Governs steady-state phenomena like heat distribution and electrostatics.
Numerical Solution:
Use the finite difference approximation:
Example:
Solve on a 2D square grid of size with boundary conditions:
- on all sides except at .
Solution:
- Set up the grid:
- Apply the finite difference formula iteratively:
- Iterations:
- .
- Solve iteratively until convergence.
Practice Question: Solve on a grid with everywhere except on the top edge.
4. Poisson's Equation
Form:
- Governs problems with distributed sources (e.g., heat with internal generation).
Numerical Solution:
Use the finite difference approximation:
Example:
Solve on a grid with on the boundaries.
Solution:
- Discretize:
- Start with :
- Iterate until convergence.
Practice Question: Solve on a grid with on the boundaries.
Summary
- Laplace's Equation describes steady-state processes.
- Poisson's Equation describes processes with distributed sources.
- Finite Difference Method is key to solving PDEs numerically.
- Iterative methods like Gauss-Seidel are used for solving grid-based equations efficiently.
Topic: Lab Works
Laboratory Works: Numerical Methods Implementation
Laboratory sessions focus on developing and testing programs to solve mathematical problems numerically using C or C++ Builder. Below are the detailed outlines, algorithms, and example programs for each topic.
1. Non-linear Equations
Objective:
Write a program to solve a non-linear equation using methods like the Bisection Method, Newton-Raphson Method, or Fixed Point Iteration.
Example: Newton-Raphson Method
Algorithm:
- Define the function and its derivative .
- Choose an initial guess .
- Iteratively update using:
- Stop when .
Program in C:
#include <stdio.h>
#include <math.h>
double f(double x) {
return x * x - 4; // Example function: x^2 - 4 = 0
}
double df(double x) {
return 2 * x; // Derivative: 2x
}
int main() {
double x0, tol, x1;
int max_iter, iter = 0;
printf("Enter initial guess: ");
scanf("%lf", &x0);
printf("Enter tolerance: ");
scanf("%lf", &tol);
printf("Enter maximum iterations: ");
scanf("%d", &max_iter);
do {
x1 = x0 - f(x0) / df(x0);
iter++;
if (fabs(f(x1)) < tol) {
printf("Root: %lf found in %d iterations\n", x1, iter);
return 0;
}
x0 = x1;
} while (iter < max_iter);
printf("Failed to converge\n");
return 1;
}
Practice: Write a program to solve using the Bisection Method.
2. Interpolation
Objective:
Develop a program to perform interpolation using Lagrange's or Newton's method.
Example: Newton's Divided Difference Method
Algorithm:
- Create a divided difference table for the given data points.
- Construct the Newton's interpolation polynomial.
Program in C:
#include <stdio.h>
void dividedDifferenceTable(double x[], double y[], int n, double diffTable[][10]) {
for (int i = 0; i < n; i++) diffTable[i][0] = y[i];
for (int j = 1; j < n; j++) {
for (int i = 0; i < n - j; i++) {
diffTable[i][j] = (diffTable[i + 1][j - 1] - diffTable[i][j - 1]) / (x[i + j] - x[i]);
}
}
}
double newtonInterpolation(double x[], double diffTable[][10], int n, double value) {
double result = diffTable[0][0];
double term = 1.0;
for (int i = 1; i < n; i++) {
term *= (value - x[i - 1]);
result += term * diffTable[0][i];
}
return result;
}
int main() {
int n;
printf("Enter the number of data points: ");
scanf("%d", &n);
double x[n], y[n], diffTable[10][10] = {0};
printf("Enter x and y values:\n");
for (int i = 0; i < n; i++) {
scanf("%lf %lf", &x[i], &y[i]);
}
dividedDifferenceTable(x, y, n, diffTable);
double value;
printf("Enter the value of x to interpolate: ");
scanf("%lf", &value);
double result = newtonInterpolation(x, diffTable, n, value);
printf("Interpolated value at x = %lf is %lf\n", value, result);
return 0;
}
Practice: Implement Lagrange's Interpolation for the same dataset.
3. Numerical Differentiation and Integration
Objective:
Write a program to compute numerical derivatives and integrals using Trapezoidal Rule or Simpson's Rule.
Example: Simpson's 1/3 Rule
Algorithm:
- Divide the interval into subintervals.
- Compute the integral:
Program in C:
#include <stdio.h>
#include <math.h>
double f(double x) {
return 1 / (1 + x * x); // Example function: 1 / (1 + x^2)
}
int main() {
double a, b, h, sum = 0.0;
int n;
printf("Enter lower limit, upper limit, and subintervals: ");
scanf("%lf %lf %d", &a, &b, &n);
if (n % 2 != 0) {
printf("Number of subintervals must be even\n");
return 1;
}
h = (b - a) / n;
for (int i = 1; i < n; i++) {
if (i % 2 == 0) {
sum += 2 * f(a + i * h);
} else {
sum += 4 * f(a + i * h);
}
}
sum += f(a) + f(b);
sum *= h / 3;
printf("Integral: %lf\n", sum);
return 0;
}
Practice: Compute the derivative of at using central difference approximation.
4. Solution of Linear Algebraic Equations
Objective:
Solve a system of linear equations using methods like Gaussian Elimination or Gauss-Seidel Iteration.
Example: Gaussian Elimination
Program in C:
#include <stdio.h>
int main() {
int n;
printf("Enter the number of equations: ");
scanf("%d", &n);
double a[n][n+1], x[n];
printf("Enter the augmented matrix:\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j <= n; j++) {
scanf("%lf", &a[i][j]);
}
}
// Forward elimination
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
double factor = a[j][i] / a[i][i];
for (int k = 0; k <= n; k++) {
a[j][k] -= factor * a[i][k];
}
}
}
// Back substitution
for (int i = n-1; i >= 0; i--) {
x[i] = a[i][n];
for (int j = i+1; j < n; j++) {
x[i] -= a[i][j] * x[j];
}
x[i] /= a[i][i];
}
printf("Solution:\n");
for (int i = 0; i < n; i++) {
printf("x%d = %lf\n", i+1, x[i]);
}
return 0;
}
Practice: Solve a system of equations using Gauss-Seidel iteration.
5. Solution of ODEs
Objective:
Implement numerical methods like Euler's Method or Runge-Kutta Methods.
Example: Runge-Kutta (4th Order)
Program in C:
#include <stdio.h>
double f(double x, double y) {
return x + y; // Example ODE: dy/dx = x + y
}
int main() {
double x0, y0, h, xn;
int n;
printf("Enter initial x, initial y, step size, and final x: ");
scanf("%lf %lf %lf %lf", &x0, &y0, &h, &xn);
while (x0 < xn) {
double k1 = h * f(x0, y0);
double k2 = h * f(x0 + h / 2, y0 + k1 / 2);
double k3 = h * f(x0 + h / 2, y0 + k2 / 2);
double k4 = h * f(x0 + h, y0 + k3);
y0 += (k1 + 2*k2 + 2*k3 + k4) / 6;
x0 += h;
}
printf("Solution at x = %
lf is y = %lf\n", xn, y0); return 0; }
**Practice:** Implement Euler's method for the same ODE.
---
### **6. Solution of PDEs**
#### **Objective:**
Solve PDEs using finite difference methods.
#### **Example: Laplace's Equation**
Solve \( \nabla^2 u = 0 \) on a 2D grid using iterative methods.
**Practice:** Implement Jacobi iteration for solving Laplace's equation.
Topic: Past Questions
Topic: Past Questions 2080
Tribhuvan University
Institute of Science and Technology
2080
Bachelor Level / third-semester / Science
Computer Science and Information Technology( CSC212 )
Numerical Method
Full Marks: 60 + 20 + 20
Pass Marks: 24 + 8 + 8
Time: 3 Hours
Candidates are required to give their answers in their own
words as far as practicable.
The figures in the margin indicate full marks.
Section A
Attempt any two questions.
1. How secant methods differs from Newton Rhapson method?
Derive the formula for Secant Method. Solve the equation Cosx + 2Sinx – x² = 0
using Secant method. Assume error precision as 0.01. Discuss the drawbacks of
the Newton Rhapson method.
2. Define the terms interpolation and extrapolation. Write
down the algorithm and program for Newton’s divided difference interpolation.
3. How Gauss Jordan method differs from Gauss Elimination
method? Solve the following system of equations using Gauss Jordan method. How
can we use Gauss Jordan method to find the inverse of a matrix? Discuss.
2x – y + 4z = 15
2x + 3y – 2z = 4
3x + 2y – 4z = -4
Section B
Attempt any eight questions.
4. Define the terms approximate errot and relative
approximate error? Discuss the working of Half Interval method for finding the
roots of non-linear equation.
5. Construct Newton’s backward difference table for given
data points and approximate the value of f(x) at x=45.
|
x |
10 |
20 |
30 |
40 |
50 |
|
f(x) |
0.985 |
0.934 |
0.866 |
0.766 |
0.643 |
6. Fit the quadratic curve through the following data points
and estimate the value of f(x) at x=2.
|
x |
1 |
3 |
4 |
5 |
6 |
|
y |
2 |
7 |
8 |
7 |
5 |
7. Factorise the following matrix using Cholesky method.
8. How can we calculate derivatives of discrete (tabulated)
functions? Write down its algorithm.
9. Find the following integral using composite trapezoidal
rule for using 2 segments (k=2) and 4 segments (k=4).
2∫4 (x³+2) dx
10. Approximate the solution of y’=3x², y(1)=1 using
Taylor’s series method using first four terms. Approximate the value of y(2).
11. Solve the Poisson’s equation ∇²f = xy and f=2 on boundary by assuming square domain 0 ≤ x ≤ 3 and 0 ≤ y ≤ 3 and h=1.
12. Write down the program for solving ordinary differential
equation using Heun’s method.
Topic: Past Questions 2079
Tribhuvan University
Institute of Science and Technology
2079
Bachelor Level / third-semester / Science
Computer Science and Information Technology( CSC212 )
Numerical Method
Full Marks: 60 + 20 + 20
Pass Marks: 24 + 8 + 8
Time: 3 Hours
Candidates are required to give their answers in their own
words as far as practicable.
The figures in the margin indicate full marks.
Section A
Attempt any two questions.
1 .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 precisionn of 0.01.
x3 + 2x – cos(x) = 4
2 .How spline interpolation differs with the Langrage’s
interpolation? Estimate the value of f(0) and f(4) using cubic spline
interpolation from the following data.
|
x |
-1 |
1 |
2 |
3 |
|
f(x) |
-10 |
-2 |
14 |
86 |
3 .What is pivoting? Why is it necessary? Write an algorithm
and program to solve the set of n linear equations using Gaussian elimination
method.
Section B
Attempt any eight questions.
4 .Calculate a real root of the following function using
bisection method correct upto 3 significant figures.
x2 – e-x = 3
5. 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.
6 .Write down the program for solving ordinary differential
equation using Heun’s method.
7 .Fit the quadratic function for the data given below using
least square method.
|
x |
1.0 |
1.5 |
2.0 |
2.5 |
3.0 |
3.5 |
4.0 |
|
f(x) |
2.7 |
4 |
5.8 |
8.3 |
11.2 |
15 |
19 |
8 .Estimate the integral value of following function from x
=1.2 to 2.4 using Simpson’s 1/3 rule.
|
x |
1.0 |
1.2 |
1.4 |
1.6 |
1.8 |
2.0 |
2.2 |
2.4 |
2.6 |
|
f(x) |
1.53 |
2.25 |
3.18 |
4.32 |
5.67 |
7.23 |
8.98 |
10.94 |
13.08 |
9. What is Gaussian integration formula? Evaluate the
following integration using Gaussian integration three ordinate formula
0∫1 Sinx/x dx
10. Solve the following set of equations using Gauss Siedal
method.
x + 2y + 3z = 4
6x + 4y + 5z = 16
5x + 2y + 3z = 12
11 .Solve the following differential equation for 0 ≤ x ≤ 1
taking h=0.5 using Runge Kutta 4th order method.
y'(x) + y = 3x with y(0)=2
12. Solve the Poisson’s equation ∇2f=3x2y
over the square domain 0 ≤ x ≤ 3, 0 ≤ y ≤ 3 with f=0 on the boundary and h=1.
Topic: Past Questions 2078
Tribhuvan University
Institute of Science and Technology
2078
Bachelor Level / third-semester / Science
Computer Science and Information Technology( CSC212 )
Numerical Method
Full Marks: 60 + 20 + 20
Pass Marks: 24 + 8 + 8
Time: 3 Hours
Candidates are required to give their answers in their own
words as far as practicable.
The figures in the margin indicate full marks.
Section A
Attempt any TWO questions:
1 .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.
2 Write matrix factorization? How can be used to solve a
system of linear equations? Factorize the given matrix A and solve the system
of equations Ax = b for given b using L and U matrices.
A =
and b = ![]()
3 .What is a higher-order differential equation? How can you
solve the higher-order differential equation? Explain. Solve the following
differential equation for 1 ≤ x ≥ 2, taking h = 0.25
, width y(1) = 1 and y‘(1)
= 2
Section B
Attempt any EIGHT questions:
4 .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.
x2 – e-x – x = 1
5 .Calculate the real root of the given equation using fixed
point iteration correct up to 3 significant figures.
2x3 – 2x = 5
6 .What is Newton’s interpolation? Obtain the divided
difference table from the following data set and estimate the f(x) at x = 2 and
x = 5.
|
x |
3.2 |
2.7 |
1.0 |
4.8 |
5.6 |
|
f(x) |
22.0 |
17.8 |
14.2 |
38.3 |
51.7 |
7 .What is linear regression? Fit the linear function to the
following data
|
x |
1.0 |
1.2 |
1.4 |
1.6 |
1.8 |
2.0 |
2.2 |
2.4 |
|
f(x) |
2.0 |
2.6 |
3.9 |
6.0 |
9.3 |
15 |
20.6 |
30.4 |
8 .What are the problems with polynomial interpolation for a
large number of data set? How such problems are addressed? Explain with an
example.
9 .Evaluate the following integration using Romberg
integration.
∫10sin2xxdx∫01sin2xxdx
10 .Solve the following set of linear equations using the
Gauss-Jordan method.
x2 + 2x3 + 3x4 =
9
7x1 + 6x2 + 5x3 +
4x4 = 33
8x1 + 9x2 + x4 =
27
2x1 + 5x2 + 4x3 +
3x4 = 23
11 .Solve the following differential equation for 1 ≤ x ≤ 2,
taking h = 0.25 using Heun’s method.
y‘(x) + x2y = 3x, with y(1) = 1
12. Consider a metallic plate of size 90cm by 90cm. The two
adjacent sides of the plate are maintained at a temperature of 1000C
and the remaining two adjacent sides are held at 2000C. Calculate
the steady-state temperature at interior points assuming a grid size of 30 cm
by 30 cm.
Topic: Past Questions Solutions
Topic: Past Questions 2080 Solutions
Section A
1. How secant method differs from Newton-Raphson method? Derive the formula for Secant Method. Solve the equation Cos(x) + 2Sin(x) - x² = 0 using Secant method. Assume error precision as 0.01. Discuss the drawbacks of the Newton-Raphson method.
Secant Method vs Newton-Raphson Method:
-
Newton-Raphson Method: It is based on an approximation of the function’s tangent at the current guess. The formula is:
Here, is the derivative of the function at .
-
Secant Method: It approximates the derivative by using two previous points, instead of calculating the derivative explicitly. The formula is:
In the Secant method, no derivative is required. This is an advantage when the derivative of the function is difficult to compute.
Derivation of the Secant Method: The Secant method uses the equation of the secant line passing through two points and . The formula for the secant line is given by:
Setting (to find the root), we get the Secant method formula:
Solving the Equation using Secant Method: We are tasked with solving:
using the Secant method.
- Initial guesses: Let’s assume and .
- Function and iteration:
- Iterations: Compute values of , update , and stop when the error is less than 0.01.
Drawbacks of the Newton-Raphson Method:
- Requires the derivative of the function, which might be difficult or impossible to compute.
- The method might not converge if the initial guess is far from the root.
- It can fail if the derivative at the root is zero or very small.
2. Define the terms interpolation and extrapolation. Write down the algorithm and program for Newton’s divided difference interpolation.
- Interpolation: Finding the value of the function within the range of known data points.
- Extrapolation: Finding the value of the function outside the range of known data points.
Algorithm for Newton’s Divided Difference Interpolation:
- Create a divided difference table for the given data points.
- The first column contains the values of .
- Each subsequent column contains the divided differences.
- The interpolating polynomial is given by:
- Evaluate the polynomial at the desired point.
3. How Gauss-Jordan method differs from Gauss Elimination method? Solve the following system of equations using Gauss-Jordan method. How can we use Gauss-Jordan method to find the inverse of a matrix? Discuss.
- Gauss-Jordan Method: It reduces the augmented matrix to the reduced row echelon form (RREF), with the goal of solving the system directly.
- Gauss Elimination Method: It reduces the matrix to upper triangular form and then performs back substitution.
Solving the system using Gauss-Jordan Method: Given the system of equations:
- Write the augmented matrix for the system:
- Use row operations to reduce the matrix to reduced row echelon form.
- The solution will be obtained from the last column.
Finding the Inverse of a Matrix Using Gauss-Jordan Method: To find the inverse of a matrix, augment the matrix with the identity matrix and use Gauss-Jordan elimination to reduce the matrix to the identity matrix. The resulting matrix on the right will be the inverse.
Section B
4. Define the terms approximate error and relative approximate error? Discuss the working of the Half Interval method for finding the roots of non-linear equation.
-
Approximate Error: The difference between successive approximations.
-
Relative Approximate Error: The approximate error relative to the current approximation.
Half Interval Method (Bisection Method):
- Choose two initial guesses, and , such that and have opposite signs.
- Compute the midpoint: .
- Evaluate . If is sufficiently close to zero or the error is small, stop; otherwise, replace one of the guesses with and repeat the process.
5. Construct Newton’s backward difference table for given data points and approximate the value of f(x) at x=45.
Given:
- Construct the backward difference table by calculating the differences.
- Use the formula for backward interpolation:
- Use the table to find the value of at .
6. Fit the quadratic curve through the following data points and estimate the value of f(x) at x=2.
Given points:
- Use the method of least squares to fit the quadratic curve .
- Solve for , , and using the normal equations.
- Substitute to estimate the value of .
7. Factorize the following matrix using the Cholesky method.
This question would require specific matrix data to perform the Cholesky decomposition.
8. How can we calculate derivatives of discrete (tabulated) functions? Write down its algorithm.
-
Forward Difference:
-
Backward Difference:
-
Central Difference:
9. Find the following integral using composite trapezoidal rule for and .
This would require applying the trapezoidal rule to the integral:
Use the formula for the composite trapezoidal rule to compute the value of the integral for the
given segments.
10. Approximate the solution of using Taylor’s series method using the first four terms. Approximate the value of .
Use the Taylor series expansion:
Substitute the known values to compute .
11. Solve the Poisson’s equation and on boundary by assuming square domain and and .
You can apply finite difference methods to solve this. Using a grid with spacing , compute the values at each grid point and solve iteratively.
12. Write down the program for solving ordinary differential equation using Heun’s method.
Heun’s method is an improved version of Euler’s method. The algorithm is:
- Compute the intermediate slope:
- Update the value:
This can be implemented in a programming language such as Python.
Topic: Past Questions 2079 Solutions
Section A
1. How secant method can approximate the root of a non-linear equation? Explain with necessary derivation. Estimate a real root of the following equation using the secant method. Assume error precision of 0.01.
Given the equation:
Secant Method:
The Secant method is used to find the roots of a non-linear equation without requiring the computation of derivatives. The Secant method formula is:
Where:
- is the function whose root we want to find.
- and are two initial guesses.
Steps to Apply Secant Method:
-
Define the function:
-
Choose initial guesses: Let's take and .
-
Compute using the Secant formula:
-
Repeat until the error precision is less than 0.01.
Iteration 1:
Iteration 2:
Continue until the error between successive approximations is less than 0.01.
2. How spline interpolation differs from Lagrange’s interpolation? Estimate the value of and using cubic spline interpolation from the following data.
Spline Interpolation vs Lagrange Interpolation:
-
Lagrange Interpolation: This method constructs a polynomial that passes through all the data points. The polynomial has degree where is the number of data points.
-
Spline Interpolation: It uses piecewise polynomials (splines) to fit the data. The most common type is cubic splines, where each piece of the polynomial is of degree 3. The advantage is that it avoids large oscillations that high-degree polynomials in Lagrange interpolation might produce.
Given Data Points:
To estimate and , we need to construct the cubic spline and use it to find these values. This typically involves:
- Solving a system of linear equations to determine the coefficients of the cubic splines.
- Using the spline formula to compute the values of and .
(For simplicity, you can use numerical software or tools like MATLAB or Python to construct and solve the cubic spline system.)
3. What is pivoting? Why is it necessary? Write an algorithm and program to solve the set of linear equations using the Gaussian elimination method.
Pivoting: Pivoting refers to the process of selecting the largest possible element (in absolute value) from the current column during Gaussian elimination. This is done to improve the numerical stability of the algorithm.
- Partial Pivoting: Choosing the largest element in the current column as the pivot.
- Complete Pivoting: Choosing the largest element in the remaining matrix (both row and column).
Algorithm for Gaussian Elimination:
- For each column, find the pivot element.
- Swap rows to place the pivot element in the current column.
- Perform row elimination to form an upper triangular matrix.
- Use back substitution to find the solution.
Section B
4. Calculate a real root of the following function using the bisection method correct up to 3 significant figures.
Given the function:
- Bisection Method works by repeatedly halving an interval and selecting the subinterval in which the function changes sign. The root is approximated as the midpoint of the interval.
Steps:
- Choose initial guesses, say and .
- Compute and .
- If and have opposite signs, compute the midpoint and evaluate .
- Repeat until the error is less than 0.001 (3 significant figures).
5. What is the fixed-point iteration method? How can it converge to the root of a non-linear equation? Also, explain the diverging cases with suitable examples.
Fixed-Point Iteration Method: This method involves rearranging the original equation into the form:
Then, starting with an initial guess , iterate using:
Convergence: The method converges if the function satisfies the condition near the root.
Divergence Cases: If , the method will not converge and may even diverge.
Example of Divergence: If , starting with , the method will diverge because .
6. Write down the program for solving ordinary differential equation using Heun’s method.
Heun’s method is a type of predictor-corrector method. The steps are:
- Compute the predictor value using Euler’s method:
- Compute the corrector value using the average of slopes:
7. Fit the quadratic function for the data given below using the least square method.
Given the data points:
To fit a quadratic curve using the least square method:
- Set up the normal equations for , , and .
- Solve the system of equations to find the values of , , and .
- Use the obtained quadratic equation to predict values for .
8. Estimate the integral value of the following function from to using Simpson’s 1/3 rule.
Given:
Simpson’s 1/3 rule is given by:
I = \frac{h}{3} \left( f(x_0) + 4 \sum_{\text{odd } i} f(x_i) + 2 \sum_{\text{even } i} f(x_i)- f(x_n) \right) ] Where .
Topic: Past Questions 2078 Solutions
Let's go ahead and solve each of the questions one by one in detail:
Section A - Attempt Any Two Questions
1. Horner's Rule for Polynomial Evaluation
Question: How can Horner's rule be used to evaluate the and of a polynomial at a given point? Explain and write an algorithm and program to calculate a real root of a polynomial using Horner’s rule.
Explanation:
Horner’s rule is an efficient method for evaluating a polynomial and its derivative. A polynomial of degree is expressed as:
In Horner’s form, this is rewritten as:
This reduces the number of multiplications and additions needed to evaluate the polynomial.
Algorithm:
- Input: Coefficients of the polynomial , value .
- Initialize: Set .
- Iterate: For each coefficient, update as .
- Output: The value of .
Program (Python Example):
def horner(coeffs, x):
result = coeffs[0]
for i in range(1, len(coeffs)):
result = result * x + coeffs[i]
return result
# Example Polynomial: 3x^3 - 5x^2 + 2x - 7
coeffs = [3, -5, 2, -7]
x = 2
print("f(x) at x =", x, "is:", horner(coeffs, x))
To Solve for the Root of a Polynomial:
You can use a root-finding method like Newton-Raphson combined with Horner's Rule to evaluate both the function and its derivative efficiently. In general, we will iterate until we get a root with the desired precision.
2. Matrix Factorization to Solve Linear Equations
Question: Write matrix factorization and solve the system of linear equations for and given below using LU Decomposition.
Given:
We need to perform LU Decomposition where , and solve the system for .
Steps for LU Decomposition:
-
Decompose into and : The matrix is decomposed into a lower triangular matrix and an upper triangular matrix .
The LU decomposition process involves solving for and , using Gaussian elimination without pivoting.
-
Solve for : Using forward substitution to solve for .
-
Solve for : Using backward substitution to solve for .
Solution:
This step is usually performed using a Gaussian elimination method, which is implemented numerically in most scientific computing tools. Here's a general approach to solve it:
- Compute and (LU Decomposition).
- Solve using forward substitution.
- Solve using backward substitution.
3. Solving a Higher-Order Differential Equation
Question: Solve the higher-order differential equation:
We will solve this second-order ODE using Euler's method for numerical approximation. The equation is already in a form suitable for splitting into a system of first-order equations:
Let:
- , so .
The system of equations is:
Steps:
- Initialize with the initial values and .
- Use Euler’s method to iteratively solve for and at each step .
Euler’s method:
Iteration:
Let’s calculate step by step:
Initial conditions: , , .
-
Step 1:
-
Step 2:
Repeat these steps for the desired range to approximate the solution.
Section B - Attempt Any Eight Questions
4. Half-Interval Method
We are tasked with solving the following equation using the Half-Interval Method (Bisection Method):
To apply the Half-Interval Method:
-
Define the function:
-
Choose an initial interval , say, and .
-
Check the signs of and :
Since and have opposite signs, there is a root between them.
-
Iterate: Find the midpoint , and evaluate . Continue halving the interval until the error is sufficiently small.
Repeat this process until you reach the desired precision.
5. Fixed-Point Iteration
We need to solve the following equation using Fixed-Point Iteration:
-
Rearrange the equation into a form :
-
Choose an initial guess , say .
-
Iterate:
Continue iterating until (desired precision).
6. Newton’s Interpolation
We are given the following data points and need to construct a Divided Difference Table to perform Newton’s interpolation:
- Construct the divided difference table for the given data.
- Use the Newton’s interpolation formula to estimate at specific points.
The formula is:
Using this, you can estimate at and .
7. Linear Regression
We need to fit a linear function to the following data using the Least Squares Method:
-
Set up the system for linear regression: We want to fit a line , where:
-
Solve the system to find the values of and that minimize the error.
8. Problems with Polynomial Interpolation
Polynomial interpolation can lead to problems, especially for large datasets. These problems include:
- Runge's Phenomenon: Polynomial interpolation can oscillate wildly at the ends of the interval when the degree of the polynomial increases.
- Overfitting: High-degree polynomials can fit the data perfectly but may not generalize well to new data points.
How to Address the Problems:
- Piecewise Interpolation: Instead of fitting a single polynomial, use piecewise interpolation (e.g., Spline Interpolation) to avoid oscillations.
- Least Squares Method: Fit a lower-degree polynomial that minimizes the error.
9. Romberg Integration
We need to evaluate the following integral using Romberg Integration:
The Romberg integration formula is a recursive method that improves the Trapezoidal rule by considering successive refinements.
The method is given by:
Continue until the desired accuracy is achieved.
10. Gauss-Jordan Method
We are given the following system of linear equations:
- Form the augmented matrix for the system.
- Perform Gaussian elimination with partial pivoting to reduce the system to an upper triangular matrix.
- Back-substitute to find the solution.
11. Heun’s Method for Differential Equations
We need to solve the differential equation:
-
Write the equation in standard form:
-
Apply Heun’s method:
-
Iterate until you reach , with .
12. Poisson’s Equation
We are given the Poisson’s equation:
on the square domain and , with boundary conditions on the boundary.
This is a typical Finite Difference Method problem where the solution is approximated by discretizing the differential equation.
- Use a grid with step size and solve for the interior points using the finite difference approximation.
Topic: Syllabus
Course Description
Course Description
This course covers solution of nonlinear equations, interpolation and approximation, numerical differentiation and integration and solution of linear algebraic equation, ordinary differential equations and partial diferential equations. it provides knowledge for numerical analysis.
Course Objectives
The general objectives of this subject are to make students familiar with the theory of numerical analysis for solving algebraic and transcendental equations, solution of ordinary and partial differential equations, numerical diferentiation and integration.
Unit Contents
1. Solution of Nonlinear Equations : 10 hrs
Introduction, Types of Equation, Errors in Computing, The Bisection Method; The Method of False Position, Newton- Raphson Method, Solution of System of Nonlinear Equation, Fixed Point Iteration and Convergence
2. Interpolation and Approximation : 10 hrs
Introduction, Errors in Polynomial Interpolation, Lagrange's Polynomials, Newton's Interpolation using Difference and Divided Differences, Cubic Spline Interpolation, Least Squares Method for Linear and Non-linear Data.
3. Numerical Differentiation and Integration : 5 hrs
Introduction to Numerical Differentiation, Newton's Differentiation Formulas, Numerical Integration (Trapezoidal Rule, Simpson's 1/3 rule, 3/8 rule); Romberg Integration; Numerical Double Integration.
4. Solution of Linear Algebraic Equations : 10 hrs
Review of the existence of solutions and properties of matrices. Consistency of a Linear System of Equations, Gaussian Elimination Method, Gauss-Jordan Method, Inverse of matrix using Gauss Elimination Method, Method of factorization, Iterative Methods(Jacobi & Gauss-Seidel Iteration),Power Method.
5. Solution of Ordinary Differential Equations : 7 hrs
Introduction to Differential Equations, Initial Value Problem, Taylor Series Method, Picard's Method, Euler's Method and Its Accuracy, Heun's method, Runge-Kutta Methods, Solutions of Higher Order Equations, Boundary Value Problems, Shooting Method and Its Algorithm.
6. Solution of Partial Differential Equations : 5 hrs
Introduction to Partial Differential Equations, Deriving Differences Equations, Laplacian Equation and Poisson's Equation.
Laboratory Works
Laboratory works will consist of program development and testing of Non-linear Equations, Interpolation, Numerical Differentiation and Integration, Linear Algebraic Equations, Ordinary and Partial Differential Equations using C or C+ I Builder.
Text and Reference Books
Text Books
- C.F. Gerald and P.O. Wheatley, “Applied Numerical Analysis”, 4th.. Edition, Addison Wesley Publishing Company, New York
- S. S Sastry, “Introduction to Methods of Numerical Analysis”,- Prentice- Hall India
Reference Books
- W. Cheney and D. Kinciad, “Ntth’erical Mathematics. and Computing”, 2nd edition, Brooks/Cole Publishing Co., 1985
- W.H. Press, B.P. Flannery et. al., “Numerical Recipes in C”, ls Edition, Cambridge Press, 1998.
No comments:
Post a Comment