title: Using MPI for simple calculation, different numbers of processes get different results?
body: <p>I am using MPI on a very simple computation of PI using numerical integration, using some mathematical rules, eventually I convert the calculation into a summation, where it has this format:</p>
  
  <p>PI = ∑(f(i)), where i start from 1 to 100000, and f(i) is a function to return some double type value based on i.</p>
  
  <p>It is quite strait forward that when programming, I can convert the sum into a for loop, iterating 100000 times. And with MPI using p processors, I divide the for loop into p segments, each processor gets 100000/p loops, (supposing 100000%p = 0). And later on using MPI_Reduce, MPI_SUM to collect those sub-results and sum them up to get the final results.</p>
  
  <p>However, when I using different numbers of processes, the final results will be slightly different, my final PI result has 12 bit precision, and the results start to be different after around 7th bit.</p>
  
  <p>I can not get the answer why the result will be different, as in my mind,  it simply does exactly same tasks no mater how the tasks are distributed.</p>
  
  <p>Any help will be appreciated very much! </p>