i have this integration equation, i want to solve it with numerical integration. am no maths pro, so i just need a way to break it down and solve using one of the numerical methods

the integration equation

i need it broken down or so i can write a program that will numerically integrate it once I input the values of B and the upper limit p.

the value of z depends on the value of p. For every slight change in p, z changes also. The formulas to calculate z is given below:

The equation for z

The equation for y

The equation for y

  • 3
    $\begingroup$ How does $p$ relate to $t,\,p_{pr}$ and $z$? Is the integral really wrt $p$ and then has $p$ as a limit of integration? $\endgroup$
    – Daryl
    Apr 30, 2013 at 5:22
  • 1
    $\begingroup$ You still haven't answered the important part of Daryl's comment - is the integral really with respect to $p$ and has $p$ as a limit of integration? I'd expect it should be something like $\int_{3}^{p} f(q) \textrm{d}q$. $\endgroup$ Apr 30, 2013 at 9:02
  • 2
    $\begingroup$ $p$ should not be the limit of integration and the variable of integration. Check your derivation of this problem. $\endgroup$
    – Emily
    May 2, 2013 at 15:21
  • 1
    $\begingroup$ @Smith Maybe it's a typo? If we're doing Riemann integration, it doesn't really make sense to have the variable of integration be a limit of integration. Consider $\int_a^x 2x\ dx$. This doesn't really mean anything. We could evaluate this to $x^2\mid_a^x$ but that's just $x^2-a^2$. The proper way to write this would be $\int_a^x 2y\ dy$. $\endgroup$
    – Emily
    May 2, 2013 at 18:32
  • 1
    $\begingroup$ @Smith then it makes no sense to integrate with respect to a constant. That would be like writing $\int_a^b x d2$. $\endgroup$
    – Emily
    May 2, 2013 at 20:24

2 Answers 2


This is a Matlab script that may be a good place to start. It sets up $F$ as a vector, finds the root for each value of $p$ and stores that as a vector. This is then used to define a vector containing the value of the function over the integration interval. You then integrate by summing over the vector and multiplying by the line element. You may need greater accuracy when finding the root so you could use the Matlab fzero function as well once you have found roughly where the root is by this method. I can email the file if you think it would be useful. If you don't have Matlab the underlying principal will be the same in another program and you could start from this method except the "sum" and "min" commands may be program specific. Apologies for poor resolution, couldn't get my head round the HTML lark so I used a tiff file...

enter image description here

  • $\begingroup$ as the commenter mentioned above that the integral equation is not correct. how did you think the solution you provided might be correct. am still trying to find out the correct form. besides i dont see the solution of p, that is the integral. and also, i dont have mathlab, but am using fortran $\endgroup$
    – Smith
    May 4, 2013 at 9:51
  • $\begingroup$ OK, first of all the objection they had was that you used the same variable name for the upper limit as you did the integration variable. While this is poor notation, I'm sad to say it happens quite regularly in physics particularly in Electrostatics; for example you might integrate over a changing radial quantity $r$ and still call the outer most limit $r$ so that it appears as a radial quantity in your final expression. That is how I interpreted this integral, a changing pressure and a final pressure but being lazy with the notation. $\endgroup$ May 4, 2013 at 10:17
  • $\begingroup$ The integral is calculated in the last line as a sum over the function $H$ multiplied by the line element $dp$. A very similar code would also work in Fortran, I just checked they have $abs$, $min$ and $sum$ commands. $\endgroup$ May 4, 2013 at 10:20
  • 1
    $\begingroup$ The equation you are after is the vertical flow equation for bottom hole pressure in natural gas wells, first developed by Sukkar and Cornell in 1955. Their paper is not open access however, but here are a few links to papers deriving similar equations as yours. The first two are lazy and use the same variable name inside the integration as they do in the upper limit:benthamscience.com/open/topej/articles/V004/1TOPEJ.pdf $\endgroup$ May 4, 2013 at 11:22
  • 1
    $\begingroup$ psig.org/papers/1990/9504.pdf $\endgroup$ May 4, 2013 at 11:22

The simpliest (and less acurate) way to numerically integrate is to compute the function in several points equally spaced in [3, p] and them compute the mean of those values multiplied by $p-3$ (Tks Graham and Petr for pointed that! )

  • $\begingroup$ I don't see how this corresponds to the integral, why divide by the number of samples (as you do when taking the mean) and what about multiplying by the line element to account for the x axis scale? $\endgroup$ May 3, 2013 at 14:40
  • $\begingroup$ @GrahamHesketh Riemann integral is defined just as a limit of such means as the distance between the points gets to 0. So the finer spacing of points, the closer to the integral the mean gets. $\endgroup$
    – Petr
    May 3, 2013 at 14:56
  • $\begingroup$ @Petr Pudlák I would say that the Rieman integral is the limit of the Rieman sum: $\sum _{i=1}^{n-1}f \left( x_{{i}} \right) \left( x_{{i+1}}-x_{{i}} \right)$ as the interval tends to zero. I don't see how that can be described as the "mean" of the samples $\frac{1}{n}\sum _{i=1}^{n-1}f \left( x_{{i}} \right)$ as the latter is divided by $n$ and not multiplied by the line element $(x_{{i+1}}-x_{{i}})$; $dx$ in the limit. Are you saying these two sums converge to the same value in the limit? I am struggling to see how that is true when the latter is independent of the x-axis scale... $\endgroup$ May 3, 2013 at 15:28
  • $\begingroup$ @GrahamHesketh Sorry, I was wrong, it's necessary to multiply the mean by $p-3$. Then if we distribute the points evenly so that $x_{i+1}-x_i=\frac{p-3}{n}$ then $\sum_{i=1}^{n-1}f(x_i)(x_{i+1}-x_i)=\sum_{i=1}^{n-1}f(x_i)\frac{p-3}{n}=\frac{p-3}{n}\sum_{i=1}^{n-1}f(x_i)$. $\endgroup$
    – Petr
    May 3, 2013 at 15:50
  • $\begingroup$ I would agree with your final equation if you did not multiply the first sum by $(p-3)$, and instead defined $x_{i+1}-x_i=(p-3)\frac{1}{n}$ but I'm guessing that is what you meant? $\endgroup$ May 3, 2013 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .