Step-by-step explanation:
The definition of g says it is the area under the graph of f(x) from 0 to x.
That is, the value of g(2) is the area of the trapezoid of height ∆x = (2-0) and bases f(0) = 1 and f(2) = 3. You know from the formula for the area of a trapezoid that it is ...
A = 1/2(b1+b2)h = (1/2)(1+3)·2 = 4
so g(2) = 4, as shown.
Then g(3) adds the area of the rectangle that is f(2)=f(3) = 3 units high and one unit wide between x=2 and x=3. So g(3) = g(2)+3 = 4+3 = 7.
Then g(5) adds the area of the triangle with height f(3)=3 and base ∆x=(5-3)=2. Of course, the area of that triangle is ...
A = 1/2bh = 1/2·2·3 = 3
which means that g(5) = g(3)+3 = 7+3 = 10.
Now it gets interesting, because f(x) is less than zero for x > 5. This means the heights of the triangles are negative, while the bases are still positive. So, the area is negative and the value of g(x) decreases for x>5.
For example, f(5) = 0 and f(7) = -3, so the area under the curve (between the graph of f(x) and the line y=0) is the area of a triangle with height -3 and base 2.
A = 1/2bh = 1/2·2·(-3) = -3
Adding this area to g(5), we find g(7) = g(5) -3 = 10 -3 = 7.
_____
In geometry, we think of area as a positive quantity always. (It takes a positive amount of paint to paint it.) In calculus, the sign of area depends on the signs of the dimensions that measure it. Area measured from left to right below the x-axis will be negative, as will area measured from right to left above the x-axis. (Area below the x-axis integrated from right to left will be positive. Negative base times negative height gives positive area.)
You probably already know that reversing the limits of an integral (integrating from b to a instead of a to b) negates the result. This is another manifestation of the way the signs of things come into play.