Skip to content
Snippets Groups Projects
Commit 4f26fdcc authored by aya.mouzahim's avatar aya.mouzahim
Browse files

23.06.21

parents d2fba2c5 97875d40
No related branches found
No related tags found
No related merge requests found
/**************************************************
TP intégrales maths
Auteurs: Denis Gremaud, Aya Mouzahim
Date 06.06.2021
Version 1.0
**************************************************/
#include "src/int_num.h"
#include "src/conv_1d.h"
#include "pgm/pgm.h"
......
#include "conv_1d.h"
// filtrage par oméga 1
double filtrage_par_s_w1(double x, double w1, double w2){
double alpha = w1/w2;
return -(sin(2 * pi * w1 * x) * sin(pi * alpha)) / (pi * alpha);
}
// filtrage par oméga 2
double filtrage_par_s_w2(double x, double w1, double w2){
double alpha = w1/w2;
return - alpha *(sin(2 * pi * w2 * x) * sin(pi * alpha)) / (pi);
}
// fonction du calcul du signal S
double s(double x, double w1, double w2){
return sin(2 * pi * w1 * x) + sin(2 * pi * w2 * x);
}
// fonction de filtrage pour la convolution
double f_conv(double x, double psi){
if (x > -psi/2 && x < psi/2)
{
......@@ -24,6 +28,7 @@ double f_conv(double x, double psi){
}
}
// fonction de convolution f_conv par s
double I_conv_f(double a, double b, double n, double psi, double w1, double w2){
double res = 0;
double d_x = (b - a) / n;
......@@ -35,6 +40,7 @@ double I_conv_f(double a, double b, double n, double psi, double w1, double w2){
return res;
}
// fonction de convolution h par s
double I_conv_h(double a, double b, double n, double psi, double w1, double w2){
double res = 0;
double d_x = (b - a) / n;
......@@ -46,6 +52,7 @@ double I_conv_h(double a, double b, double n, double psi, double w1, double w2){
return res;
}
// fonction h autre fonction de filtrage pour la convolutuion
double h(double x, double psi){
return (1/sqrt(2*pi*psi)) * exp(-pow(x, 2.0) / (2*psi));
}
#include "int_num.h"
// fonction de départ
double f(double x){
return -((2*x -1) / exp(pow(x,2) - x + 2));
}
// intégrale de la fonction de départ
double f_intergrale(double a, double b){
double integrale_a = exp(-(pow(a,2) - a + 2));
double integrale_b = exp(-(pow(b,2) - b + 2));
return integrale_b - integrale_a;
}
// calcul de l'intégrale grâce a la methode du rectangle à gauche
double I_rect(double a, double b, double n){
double res = 0;
double d_x = (b - a) / n;
......@@ -19,14 +22,17 @@ double I_rect(double a, double b, double n){
return res;
}
// calcul erreur avec fonction du rectangle à gauche
double E_rect(double a, double b, double n){
return fabs((f_intergrale(a, b) - I_rect(a, b, n)) / f_intergrale(a, b));
}
// calcul erreur avec fonction du trapèze
double E_trapeze(double a, double b, double n){
return fabs((f_intergrale(a, b) - I_trapeze(a, b, n)) / f_intergrale(a, b));
}
// calcul de l'intégrale grâce a la methode du trapèze
double I_trapeze(double a, double b, double n){
double res = 0;
double d_x = (b - a) / n;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment