-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpsonsOneThird.c
More file actions
47 lines (43 loc) · 1.06 KB
/
SimpsonsOneThird.c
File metadata and controls
47 lines (43 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# include <stdio.h>
# include <math.h>
# include <stdbool.h>
bool isMethodeApplicable(float a[n][n+1]);
float findSum (int i , float a[n][n+1]);
void findValues (a,maxiterations,n,values_old);
int main (){
return 0;
}
// checking if the formula can be applied or not
bool isMethodeApplicable(float a[n][n+1]){
for(int i =0 ; i < n ; i++){
for(int j =0 ; j < n ; j++) {
if(fabs(a[i][i]>findSum(i,a)))
break;
else
return false;
}
}
return true;
};
// returnimg the sum of the matrix
float findSum (int i , float a[n][n+1]){
float sum = 0;
for(int j = 0 ; j < n ; j++){
if(i!=j)
sum += fabs(a[i][j]);
}
return sum;
};
void findValues (a,maxiterations,n,values_old){
int sum,values_new;
for(int k = 1 ; k < maxiterations ; k++){
for ( int i = 0 ; i < n ; i++){
sum = 0;
for (int j = 0 ; j < n ; j++){
if (i != j)
sum += a[i][j]*values_old[j];
}
values_new [i] = (a[i][n] - sum)/a[i][j];
}
}
}