REPUBLIQUE DU REPUBLIC OF
CAMEROUN CAMEROON
********* *********
Paix-Travail-Patrie Peace-Work-Fatherland
*********FACULTES DES *********
SCIENCES FACULTY OF SCIENCE
********* *********
UNIVERSITE DE DOUALA UNIVERSITE DE DOUALA
********* *********
MINISTRY OF HIGHER
Département de Mathématiques et Informatique
Department of mathematics and Computer Science
TPE INF448 :Résolution Numériques Des Equations
Non Linéaires De La Forme f(x)=0
Membres du groupe
Numero Noms et prenoms Matricules
1 TAPTUE TAPTUE ARTHUR DIMITRI 21S77299
2 BILONG OCEANNA ARIELLE 19S36565
3 NANA NANA FRANCINE DARNELLE 21S57037
4 NJAB BONGA MICHEL BENJAMIN 21S57048
3 KAMDEM YOUMBISSI CHRISPPO 18S08357
Sous la direction de : Dr NOUMSI
Année académique : 2024-2025
I.Méthode du point fixe(approximations successives )
main.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "fixpoint.h"
#include "fixpoint.c"
int main() {
double init_guess, precision, lower_bound, upper_bound, result;
int max_iterations, count;
int repeat = 1;
while (repeat) {
system("clear");
printf("\n==== MÉTHODE DU POINT FIXE POUR RÉSOLUTION DE f(x)=0 ====\n\n");
// Saisie utilisateur
saisir_donnees(&init_guess, &precision, &max_iterations, &lower_bound, &upper_bound);
// Calcul
appliquer_point_fixe(init_guess, precision, max_iterations, &count, &result);
// Résultat
afficher_resultat(result, count, max_iterations);
// Répéter ?
int choix;
do {
printf("\nSouhaitez-vous recommencer ? (1 = Oui, 0 = Non): ");
scanf("%d", &choix);
} while (choix != 0 && choix != 1);
repeat = choix;
}
return 0;
}
fixpoint.c
#include <stdio.h>
#include <math.h>
#include "fixpoint.h"
void saisir_donnees(double *x0, double *eps, int *N, double *a, double *b) {
int valide = 0;
while (!valide) {
printf("Entrez la borne a (inférieure) : ");
scanf("%lf", a);
printf("Entrez la borne b (supérieure) : ");
scanf("%lf", b);
if (*b <= *a) {
printf("Erreur : b doit être strictement supérieur à a.\n");
continue;
}
if (fonction_f(*a) * fonction_f(*b) >= 0) {
printf("L'intervalle choisi ne convient pas : pas de changement de signe de f(x).\n");
continue;
}
valide = 1;
}
do {
printf("Valeur initiale x0 (dans [%.2lf, %.2lf]) : ", *a, *b);
scanf("%lf", x0);
} while (*x0 < *a || *x0 > *b);
printf("Précision epsilon : ");
scanf("%lf", eps);
printf("Nombre maximal d'itérations : ");
scanf("%d", N);
}
double fonction_f(double x) {
return log(2*x + 1) - x*x - x;
}
double fonction_g(double x) {
return log(2*x + 1) - x*x;
}
void afficher_etape(int n, double x_prec, double fx_prec, double x_suiv, double fx_suiv) {
printf("It %2d : x = %.10lf | f(x) = %.10lf | g(x) = %.10lf | f(g(x)) = %.10lf\n",
n, x_prec, fx_prec, x_suiv, fx_suiv);
}
void appliquer_point_fixe(double x0, double eps, int N, int *compteur, double *solution) {
double x1, ecart;
*compteur = 1;
x1 = fonction_g(x0);
ecart = fabs(x1 - x0);
afficher_etape(*compteur, x0, fonction_f(x0), x1, fonction_f(x1));
while (ecart > eps && *compteur < N) {
x0 = x1;
x1 = fonction_g(x0);
ecart = fabs(x1 - x0);
(*compteur)++;
afficher_etape(*compteur, x0, fonction_f(x0), x1, fonction_f(x1));
}
*solution = x1;
}
void afficher_resultat(double solution, int it, int max_it) {
if (it < max_it && solution != INFINITY) {
printf("\nApproximation de la solution : %.12lf\n", solution);
printf("Nombre d'itérations : %d\n", it);
} else {
printf("\nÉchec de la convergence dans le nombre d'itérations alloué.\n");
}
}
fixpoint.h
#ifndef _FIXPOINT_H_
#define _FIXPOINT_H_
void saisir_donnees(double *x0, double *eps, int *N, double *a, double *b);
double fonction_f(double x);
double fonction_g(double x);
void afficher_etape(int n, double x0, double fx0, double x1, double fx1);
void appliquer_point_fixe(double x0, double eps, int N, int *iter, double *sol);
void afficher_resultat(double solution, int iter, int N);
#endif