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?

One approach is to integrate $\int_a^b |f(x)-g(x)|\;dx$, but in practice this usually means you need to know which of $f$ and $g$ is the larger function, which could change at some points in the interval $[a,b]$. One method of determining this behavior is to graph the functions. But this can also be done without graphing.
Suppose $f$ and $g$ are continuous on $[a,b]$ and that $f(a)=g(a)$ and $f(b)=g(b)$ and $f(x) \neq g(x)$ on $(a,b)$. By continuity, the function $f-g$ is either non-negative on $(a,b)$ or non-positive on $(a,b)$. We can determine which by choosing and value $c$ between $a$ and $b$.
So, in your example, to determine which function is greater on the interval $[0,1]$ we can choose to evaluate each function at $1/2$: $f(1/2)=7/8$ and $g(1/2)=1/4$. Thus $f \geq g$ on $[0,1]$ and so the area is $\int_0^1 f(x)-g(x)\;dx$ on this interval.
You can repeat this process on each interval between points of intersection.
