Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mpi.h>
- #include <stdio.h>
- #include <string.h>
- #define SIZE 1000
- float f (float x) {
- return 4/(1+x*x);
- }
- float integrale(int a, int b, int n){
- float integral;
- float h;
- float x;
- int i;
- h = (float)(b-a)/n;
- integral = (f(a) + f(b))/2;
- for (i=1, x=a ; i<=n-1 ; i++){
- x += h;
- integral += f(x);
- }
- integral *= h ;
- return integral;
- }
- int main(int argc, char *argv[]){
- printf("pi : %f\n", integrale(0, 1, 100));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement