Order of solving definite integrals I've been coming across several definite integrals in my homework where the solving order is flipped, and am unsure why.  Currently, I'm working on calculating the area between both intersecting and non-intersecting graphs.
According to the book, the formula for finding the area bounded by two graphs is
$$A=\int_{a}^{b}f(x)-g(x) \mathrm dx$$
For example, given $f(x)=x^3-3x^2+3x$ and $g(x)=x^2$, you can see that the intersections  are  $x={0, 1, 3}$ by factoring.  So, at first glance, it looks as if the problem is solved via
$$\int_0^1f(x)-g(x)\mathrm dx+\int_1^3f(x)-g(x)\mathrm dx$$
However, when I solved using those integrals, the answer didn't match the book answer, so I took another look at the work.  According to the book, the actual integral formulas are
$$\int_0^1f(x)-g(x)\mathrm dx+\int_1^3g(x)-f(x)\mathrm dx$$
I was a little curious about that, so I put the formulas in a grapher and it turns out that $f(x)$ and $g(x)$ flip values at the intersection $x=1.$
So how can I determine which order to place the $f(x)$ and $g(x)$ integration order without using a graphing utility?  Is it dependent on the intersection values?

You are, I hope, not quoting your calculus book correctly.
The correct result is:
Suppose that $f(x) \ge g(x)$ in the interval from $x=a$ to $x=b$.  Then the area of the region between the curves $y=f(x)$ and $y=g(x)$, from the line $x=a$ to the line $x=b$, is equal to
$$\int_a^b(f(x)-g(x))\,dx.$$
The condition $f(x)-g(x) \ge 0$ is essential here.
In your example, from $x=0$ to $x=1$ we have $f(x) \ge g(x)$, so the area from $0$ to $1$ is indeed
$\int_0^1 (f(x)-g(x))\, dx$.
However, from $x=1$ to $x=3$, we have $f(x) -g(x) \le 0$, the curve $y=g(x)$ lies above the curve $y=f(x)$.  So the area of the region between the two curves, from $x=1$ to $x=3$, is $\int_1^3(g(x)-f(x))\,dx$.
To find the full area, add up.
Comment: When you calculate $\int_a^b h(x)\,dx$, the integral cheerfully "adds up" and does not worry about whether the things it is adding up are positive or negative.  This often gives exactly the answer we need. For example, if $h(t)$ is the velocity at time $t$, then $\int_a^bh(t)\,dt$ gives the net displacement (change of position) as time goes from $a$ to $b$. The integral takes account of the fact that when $h(t)<0$, we are going "backwards."
If we wanted the total distance travelled, we would have to treat the parts where $h(t) \le 0$ and the parts where $h(t)\ge 0$ separately, just as we had to in the area case. 
For determining where $f(x)-g(x)$ is positive, negative, we can let $h(x)=f(x)-g(x)$, and try to find where $h(x)$ is positive, negative.  A continuous function $h(x)$ can only change sign where $h(x)=0$. (It need not change sign there.  For example, if $h(x)=(x-1)^2$, then $h(1)=0$, but $h(x)$ does not change sign at $x=1$.)
If the solutions of $h(x)=0$ are easy to find, we can quickly determine all the places where there might be a change of sign, and the rest is straightforward. Otherwise, a numerical procedure has to be used to approximate the roots.
