use R's integrate()