Formula for computing integrals For computing derivative of a function, we can use the definition of a derivative, i.e. $$\lim\limits_{h \to 0}\frac{f(x+h)-f(x)}{h}.$$
Is there some for computing integrals too?
 A: Yes, we can use Riemann sums which says that: $$\int_a^bf(x)\,\mathrm dx=\lim\limits_{n\to\infty}\sum_{i=1}^{n}f(x_i^*)\Delta x$$ where: $$\Delta x=\dfrac{b-a}{n}$$ and: $$x_i^*=a+(\Delta x)i$$
So for example, let's compute the following integral using Riemann sums: $$\int_{1}^{3}(x^2-x+1)\,\mathrm dx$$ To find it, we first need to know some useful sums: $$\sum_{i=1}^n k=kn\quad\color{grey}{\text{and}}\quad\sum_{i=1}^n i=\dfrac{n(n+1)}{2}\quad\color{grey}{\text{and}}\quad\sum_{i=1}^n i^2=\dfrac{n(n+1)(2n+1)}{6}.\tag{$\star$}$$
So in our particular case: $\Delta x=\dfrac{3-1}{n}=\dfrac2n$ and so: $x_i^*=1+\dfrac{2i}n$. Since in our example we integrate the function $f(x)=x^2-x+1$, then: $$\begin{align}\require{cancel}
f(x_i^*)&=\left(1+\dfrac{2i}{n}\right)^2-\left(1+\dfrac{2i}{n}\right)+1\\
&=1+\dfrac{4i}{n}+\dfrac{4i^2}{n^2}\cancel{-1}-\dfrac{2i}{n}\cancel{+1}\\
&=1+\dfrac{2i}{n}+\dfrac{4i^2}{n^2}.
\end{align}$$
Now, by the Riemann sums definition: 
$$\begin{align}
\int_1^3(x^2-x+1)\,\mathrm dx&=\lim_{n\to\infty}\sum_{i=1}^n f(x_i^*)\Delta x\\
&=\lim_{n\to\infty}\sum_{i=1}^n \left[1+\dfrac{2i}{n}+\dfrac{4i^2}{n^2}\right]\dfrac2n\\
&=\lim_{n\to\infty} \left[\sum_{i=1}^n1+\sum_{i=1}^n\dfrac{2i}{n}+\sum_{i=1}^n\dfrac{4i^2}{n^2}\right]\dfrac2n\\
&=\lim_{n\to\infty} \left[\color{darkmagenta}{\sum_{i=1}^n1}+\dfrac{2}{n}\color{blue}{\sum_{i=1}^ni}+\dfrac{4}{n^2}\color{green}{\sum_{i=1}^ni^2}\right]\dfrac2n\\
&\overset{\displaystyle(\star)}=\lim_{n\to\infty} \left[\color{darkmagenta}n+\dfrac{2}{n}\color{blue}{\dfrac{n(n+1)}{2}}+\dfrac{4}{n^2}\color{green}{\dfrac{n(n+1)(2n+1)}{6}}\right]\dfrac2n\\
&=\lim_{n\to\infty} \left[2+\dfrac{4}{n^2}\dfrac{n(n+1)}{2}+\dfrac{8}{n^3}\dfrac{n(n+1)(2n+1)}{6}\right]\\
&=\lim_{n\to\infty} \left[2+2\dfrac{n^2+n}{n^2}+\dfrac{4}{3}\dfrac{2n^3+\mathcal O(n)}{n^3}\right]\\
&=2+2+\dfrac43\cdot2\\
&=4+\dfrac83=\dfrac{20}3.
\end{align}$$
To be sure, let's check the actual value of that integral using the fundamental theorem of calculus: $$\int_1^3(x^2-x+1)\,\mathrm dx=\left(\dfrac{x^3}3-\dfrac{x^2}2+x\right)\left|\right._{x=1}^{x=3}=\left(\dfrac{3^3}3-\dfrac{3^2}2+3\right)-\left(\dfrac{1^3}3-\dfrac{1^2}2+1\right)=\dfrac{20}3\,\color{green}\checkmark$$

The general idea of Riemann sums comes from the geometrical interpretation of the integral. If you have the integral of a function $f(x)$ from $a$ to $b$, then its value is exactly equal to the area beneath the curve of the graph of $f(x)$. See the diagram below:
$\phantom{X}$
Now we can approximate this area by making small rectangles below the graph and summing them all up. And what the Riemann sum do is that as the number of those rectangles goes to infinity (and the rectangles get narrow enough) then if we sum them all up we will get the exact value of our integral. 
$\phantom{X}$
The following theorem states that precisely:

Suppose that $f$ is integrable on $[a,b]$. Then for every $\epsilon>0$ there is some $\delta>0$ such that, if $\mathbf P=\{t_0,\ldots,t_n\}$ is any partition of $[a,b]$ with all lengths $t_i-t_{i-1}<\delta$, then $$\left|\,\sum_{i=1}^n f(x_i)(t_i-t_{i-1})-\int_a^bf(x)\,\mathrm dx\,\right|<\epsilon,$$ for any Riemann sum formed by choosing $x_i$ in $[t_{i-1},t_i]$.

NB: We can also use trapezoids instead of rectangles.

To learn more:


*

*Check Khan|Academy's section on the topic.

*Wiki and MathWorld on Riemann sums.

*Some random notes: 1, 2, 3.

A: Let $f$ be a function whose domain includes the interval $[a,b]$  and which is bounded on $[a,b]$. For each partition $\{a_0,a_1,a_2,\ldots,a_n\}$ of $[a,b]$ with 
$$a=a_0<a_1<a_2<\cdots<a_n=b$$let $l$ and $m$ be given by $$l=\sum_{r\,=\,1}^n (a_r-a_{r-1})\times\inf\{f(x):a_{r-1}\le x\le a_r\}$$
$$m=\sum_{r\,=\,1}^n (a_r-a_{r-1})\times\sup\{f(x):a_{r-1}\le x\le a_r\}$$
Then let $L$ be the set of numbers $l$ arising in that way from all the partitions of $[a,b]$ and similarly let $M$ be the set of all numbers $m$ arising in that way. If there are some partitions which lead to both 
$$\underbrace{l_1,l_2,l_3,\ldots}_{\in\,L}\quad\text{and}\quad\displaystyle \underbrace{m_1,m_2,m_3,\ldots}_{\in\,M}$$
such that the two sequences have the same limit $\alpha$ then $f$ is said to be integrable over $[a,b]$ and $\alpha$ is called its integral. We write 
$$\int_a^bf=\alpha\quad\text{or}\quad\int_a^bf(x)\,\mathrm{d}x=\alpha$$
A: In order to compute the value of the given integral, you often use the fundamental theorem of calculus, which states: Let $f$ be a bounded function on a finite interval $[a,b]$ (that is riemann integrable) if there exist a differentiable function $F$ on $[a,b]$ such that $F'= f$ then $$\int_{a}^{b} f(x)dx = F(b)-F(a)$$
A: More generally, a Riemann Sum can be defined as follows  $$\int_a^bf(x)\,\mathrm dx=\lim\limits_{\|P\|\to0}\sum_{i=1}^{n}f(x_i^*)(\Delta x)_i$$ where: $$(\Delta x)_i=x_i-x_{i-1}$$
$$x_{i-1}\le x_i^*\le x_i$$
$P=\{a=x_0\lt x_1\lt x_2\lt ...\lt x_n=b\}$ is called a partition on [a,b]
$$\|P\|=\max((\Delta x)_1,(\Delta x)_2,(\Delta x)_3,...,(\Delta x)_n)$$
Setting $(\Delta x)_i=(\Delta x)_j=\frac{b-a}{n}$ is one way of partitioning the interval [a,b], but it's not the only way.
Consider
$$\int_a^b\sqrt{x}\,\mathrm dx$$
It may make more sense to partition [a,b] such that $\sqrt{x_i}-\sqrt{x_{i-1}}$ is a constant.
