0% found this document useful (0 votes)
10 views2 pages

TP3 2425 Eng

The document outlines a practical work (TP) focused on implementing and comparing two numerical methods for solving the equation f(x) = 0: the Bisection Method and an iterative method based on a specific scheme. It provides detailed instructions for implementing both methods, including function definitions, arguments, expected results, and example functions. Additionally, it suggests a comparison of the two methods based on their iteration performance for a given function over a specified interval.

Uploaded by

nadia
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)
10 views2 pages

TP3 2425 Eng

The document outlines a practical work (TP) focused on implementing and comparing two numerical methods for solving the equation f(x) = 0: the Bisection Method and an iterative method based on a specific scheme. It provides detailed instructions for implementing both methods, including function definitions, arguments, expected results, and example functions. Additionally, it suggests a comparison of the two methods based on their iteration performance for a given function over a specified interval.

Uploaded by

nadia
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/ 2

Scientific Computing - TP3: Numerical

Resolution of the Equation f (x) = 0

Objective of this TP
The goal of this practical work (TP) is to implement two methods for the nu-
merical resolution of the equation f (x) = 0 and compare these methods.

1 Iterative Method 1: Bisection Method


We consider a continuous and strictly monotonic function f on the interval [a, b].

1. Implementation
Write a function iterativemethod1(f, a, b, epsilon, Nmax) that returns
the approximate zero x∗ of a continuous, strictly monotonic function f on [a, b]
using the bisection method and also returns the number of iterations.
Function Arguments:
• f: The function to solve.
• a, b: Real numbers such that a < b.
• epsilon: A real number ϵ > 0.
• Nmax: Maximum number of iterations.
Expected Result: The function should return the approximate value of
x∗ with a precision of ϵ and the number of iterations. If f (a) · f (b) > 0, the
function should return an error message indicating that f (a) and f (b) do not
have opposite signs.
The stopping criterion is |bn − an | ≤ ϵ.

2. Example Function
Consider the continuous function on [1, 2]:
f (x) = ln(1 + x2 ) − sin(x)
Graphically justify that the equation f (x) = 0 admits a unique solution in [1, 2].
Test the function with ϵ = 10−5 and N max = 20.

1
2 Iterative Method 2
We consider a continuous function f on [a, b] such that f (a) ̸= f (b).
The numerical approximation of the root of the equation f (x) = 0 is obtained
using the following iterative scheme:
b−a
(M I)n : xn+1 = xn − f (xn ), x0 ∈ [a, b]
f (b) − f (a)

1. Implementation
Write a function iterativemethod2(a, b, x0, f, epsilon) that returns two
lists: one containing the iterates x = [x0 , x1 , x2 , . . .] and the other containing
y = [f (x0 ), f (x1 ), f (x2 ), . . .].

2. Example
Take x0 = 2 and ϵ = 10−2 .

3 Comparison of the Two Methods


Compare the two methods in terms of the number of iterations required to
approximate the solution x∗ of the function f (x) = cos(2x) − x2 on the interval
[0, π4 ] for N max = 1000 and ϵ ∈ {10−n , 2 ≤ n ≤ 8}. Draw conclusions.

You might also like