0% found this document useful (0 votes)
29 views8 pages

Lab 4

The document outlines a series of numerical analysis lab exercises for a course, covering tasks such as calculating errors for floating-point values, evaluating thermometer accuracy, and analyzing sensor performance. It includes programming assignments using C for various numerical methods including Bisection, Newton-Raphson, Secant, and Müller methods, with specific instructions for each lab. The labs require students to compute errors, find roots, and display results with specified precision.

Uploaded by

Gaurab Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views8 pages

Lab 4

The document outlines a series of numerical analysis lab exercises for a course, covering tasks such as calculating errors for floating-point values, evaluating thermometer accuracy, and analyzing sensor performance. It includes programming assignments using C for various numerical methods including Bisection, Newton-Raphson, Secant, and Müller methods, with specific instructions for each lab. The labs require students to compute errors, find roots, and display results with specified precision.

Uploaded by

Gaurab Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

MA 542 - Numerical Analysis

Lab - 1 (Date - 24/07/2025)

1. You are given two arrays of floating-point numbers representing the true values
and their corresponding approximate values:

• True Values: {100, 200, 300}

• Approximate Values: {98, 195, 290}

Task:
Write a C program to:
1. Compute the Absolute Error for each pair.

2. Compute the Relative Error for each pair.

3. Compute the Percentage Error for each pair.

4. Finally, calculate and display:

• The Average Absolute Error


• The Average Relative Error
• The Average Percentage Error

2. Two thermometers give different temperature readings for the same set of mea-
surements. You are required to determine which thermometer provides more accurate
results.
Given:

• True Temperatures: {37.0, 38.0, 36.5, 37.5}

• Thermometer A Readings: {36.8, 38.2, 36.0, 37.2}

• Thermometer B Readings: {36.9, 38.1, 36.7, 37.6}

Task: Write a C program to:


1. Compute the percentage error for each reading of both Thermometer A and
Thermometer B.

1
2. Calculate the average percentage error for both thermometers.

3. Determine which thermometer is more accurate based on the average per-


centage error.

3. You are tasked with evaluating the performance of three different sensors (Sensor
A, Sensor B, Sensor C) that are used to measure pressure in a scientific experiment.
Given:

• True Pressure Values (in Pascals): {102.4, 98.7, 100.5, 101.3, 99.9}

• Sensor A Readings: {101.9, 97.8, 100.0, 100.9, 100.1}

• Sensor B Readings: {102.0, 98.5, 100.6, 101.5, 100.0}

• Sensor C Readings: {102.2, 99.2, 100.4, 101.1, 99.6}

Tasks: Write a C program to:

1. Compute the absolute error, relative error, and percentage error for each
reading of all three sensors.

2. Compute the average absolute error, average relative error, and average
percentage error for each sensor.

3. Rank the sensors from most accurate to least accurate based on:

• Average absolute error


• Average percentage error

4. Display the result in tabular format.

2
MA 572 - Numerical Analysis

Lab - 2 (Date - 31/07/2025)


5
(x3 + y 2 ) 2
1. Consider the function f = . Let ϵz , ϵw and ϵf denote the percentage
z 4 sinw
errors in z , w and f respectively, and x = y = z = w = 1.0 . If ϵz = 0.2%,
ϵw = 0.5% and ϵf = 1.65%, then find the relation between ϵx and ϵy , where ϵx and
ϵy are the percentage errors in x and y respectively.

2. Use the Bisection Method to find the smallest positive root of the equation:

tan(x) + tanh(x) = 0

Compute the root correct to six decimal places.

Instructions:

• Choose a suitable interval [a, b] that contains the smallest positive root.

• Ensure that the function changes sign over [a, b], i.e., f (a) · f (b) < 0.

• Use the Bisection Method iteratively to narrow down the root until the absolute
error is less than 10−6 .

• Display the following:

– The computed root (up to six decimal places),


– The number of iterations required,
– The final absolute error.

3
MA 572 - Numerical Analysis

Lab - 3 (Date - 06/08/2025)

1. Using the Newton-Raphson method, determine a simple root of the following


function:
f (x) = x log10 x − 12.34
Perform the calculations iteratively until the result converges to four decimal
place precision, i.e., when the absolute difference between successive approxima-
tions is less than
|xn+1 − xn | < 10−4
Use the initial guess:
x0 = 10
Your program should:

• Compute and display f (x) and f ′ (x) at each iteration.

• Show the updated value of xn at each step.

• Stop when |xn+1 − xn | < 10−6 .

• Display the final root with six decimal accuracy.

2.(a) Using the Newton-Raphson method (suitable for multiple roots), determine
a multiple root of the following function:

f (x) = x3 + 2x2 − 7x + 4

It is known that the multiple root has a multiplicity of 2.


Perform the calculations iteratively until the result converges to six decimal place
precision, i.e.,
|xn+1 − xn | < 10−6
Use the initial guess:
x0 = 1.5
Your program should:

• Use the Newton-Raphson formula for known multiplicity 2.

• Compute and display f (xn ), f ′ (xn ), and updated xn at each iteration.

4
• Stop when |xn+1 − xn | < 10−6 .

• Display the final root with six decimal accuracy.

(b) Using a suitable Newton-Raphson method, determine a multiple root of


the following function:
f (x) = x3 − 11x2 + 39x − 45
Here, the multiplicity of the root is not known in advance.
Perform the calculations iteratively until the result converges to six decimal place
precision, i.e.,
|xn+1 − xn | < 10−6
Use the initial guess:
x0 = 4.6
Your program should:
• Display at each iteration:

– f (xn ), f ′ (xn ), f ′′ (xn ) , and xn+1 .

• Stop when |xn+1 − xn | < 10−6 .

• Display the final root with six decimal accuracy.


3. Using the Newton-Raphson method, determine a complex root of the fol-
lowing function:
f (x) = x2 + 4
Perform the calculations iteratively until the result converges to six decimal
place precision, i.e., when the absolute difference between successive approxima-
tions is less than
|xn+1 − xn | < 10−6
Use the initial guess:
x0 = 1 + i
Your program should:
• Compute and display f (x) and f ′ (x) at each iteration.

• Show the updated value of xn at each step.

5
• Stop when |xn+1 − xn | < 10−6 .

• Display the final complex root with six decimal accuracy.

6
MA 572 - Numerical Analysis

Lab - 4 (Date - 21/08/2025)

1. Using the secant method, determine the zeros of the function:

f (x) = e−x · (x2 + 5x + 2) + 1


Perform the calculations iteratively until the result converges to six decimal pre-
cision (10−6 ). Use the initial guesses x0 = −1.5 and x1 = −3. Clearly display
all intermediate steps, including the function values and approximations for each
iteration.

2. Write a program to find the root of the following nonlinear equation using the
fixed-point iteration method:

e−x cos(x) − x2 = 0
Your program should:

• Accept an initial guess x0 from the user.

• Iteratively calculate the next approximations for x.

• Stop the iteration when the absolute difference between consecutive approxi-
mations is less than 10−6 .

• Display:

– The approximate root of the equation.


– The number of iterations taken.

Additionally, apply Aitken’s method to the fixed-point iterates in order to acceler-


ate convergence. Display the approximate root and the number of iterations required
after applying Aitken’s method.

3. Solve the following polynomial equation to find all real roots using the Müller
method:

f (x) = x4 − 10x3 + 35x2 − 50x + 24 = 0


Instructions:

7
• Initial Guesses: Take different sets of initial guesses for all the real roots.

• Stopping Criteria: The method should stop when the absolute difference
between successive approximations is smaller than a tolerance of 10−6 . Specif-
ically, stop iterating when:

|xn+1 − xn | < 10−6

Hint: The Müller method is an iterative numerical technique to find the roots of
nonlinear equations. It approximates the function by a quadratic polynomial passing
through three points and refines the root estimate based on where the quadratic
intersects the x-axis.

You might also like