Loosely speaking, the centroid of a two-dimensional object is the point where you could place a pencil and the object would balance. \( \require{color} \)

The centroid of a curve is \( \left ( \displaystyle \frac {1}{L} \int_a^b x\, dL,\ \frac {1}{L} \int_a^b y\, dL, \right ) \), where \( L \) is the length of the curve.

For example, if you want to know the centroid of the curve \( y = x^3 \) on the interval \( [0,1] \), then you would proceed as follows.

- Find the length of the curve: \( L = \int\, dL \), where \( dL \) is the arclength parameter, \( dL=\sqrt {\left(\frac{dx}{dt}\right)^2 +\left(\frac{dy}{dt}\right)^2}\,dt \). In this case, since \( y = x^3 \) is a function of
*x*, it makes sense to use \( x \) as the independent variable \( t \), so \( \frac{dx}{dx} = 1\). \( y = x^3 \), so \( \frac{dy}{dt} = 3x^2 \) and \( dL = \sqrt{ 1 + 9x^4}\,dx \). \( L = \displaystyle \int_0^1 \sqrt { 1 + 9x^4}\,dx \). When you ask Maxima to evaluate this, it gives you back the same thing you asked for, which doesn't really help. The**romberg()**command is a way to do numerical integration when**integrate()**doesn't work. The syntax is the same, you just change the word integrate to romberg. L:romberg(1+sqrt(1+9*x^4),x,0,1); returns 1.547866066810343 and since we labeled it L, we can use that in other parts of the problem.. - Find the x-coordinate of the centroid: \( \bar x= \displaystyle \frac 1 L \int_0^1 x \sqrt { 1 + 9x^4} \, dx \). Maxima will evaluate this integral, but it involves \( \ln (-1) \), which isn't really covered in introductory calculus. Since we've already gone to decimals for the arclength, we might as well stick there and use romberg() for the this part as well. Since we have already assigned L to be the arclenth of 1.547866, we can just put an L in the formula.
- Find the y-coordinate of the centroid: \( \bar y= \displaystyle \frac 1 L \int_0^1 {\color{red} y} \sqrt { 1 + 9x^4} \, dx \). However, we need to replace \( {\color{red}y} = x^3 \) into the formula to get \( \bar y= \displaystyle \frac 1 L \int_0^1 x^3 \sqrt { 1 + 9x^4} \, dx \). The integrate() command will work, but we might as well stick with romberg() since we've been using it so far.

```
L:romberg(sqrt(1+9*x^4),x,0,1);
xbar:1/L*romberg(x*sqrt(1+9*x^4),x,0,1);
ybar:1/L*romberg(x^3*sqrt(1+9*x^4),x,0,1);
```

This gives us the length of the curve 1.547866066810343 and the coordinates of the centroid (0.60864884735005,0.3663678347991).

Notice that all three integrals above are essentially the same, except for the factor in the integrand. We can use Maxima's functions to create an integral that simplifies this.

`M(t):=romberg(t*sqrt(1+9*x^4),x,0,1)$`

The *t* in the function is the additional factor that needs thrown into the integrand. It could be any variable except one already in the integral. The dollar sign at the end of the function suppresses the output. So, with the definition of M, we could now do this:

```
M(t):=romberg(t*sqrt(1+9*x^4),x,0,1)$
L:M(1);
xbar:M(x)/L;
ybar:M(y)/L;
```

Note that the notation for moments is not the same as we're using here. \( M_x \) means the moment about the x-axis, which means the extra factor is the distance from the x-axis, and that is *y*, so it would be M(y) in Maxima.

According to Pappus:

The area of a surface generated by rotating a curve about an axis (of rotation), which does not pass through the curve, is the length of the curve times the distance traveled by the centroid of the curve.

The distance from the centroid to the x-axis is the radius of rotation and is \(r = y = 0.3663678347991 \). So the length of the curve times the distance traveled by \(A = 2\pi r L \) or in this case, \(A = 2 \pi y L \), which is \(2 \pi (0.3663678347991) (1.547866066810343 ) = 3.563121122\).

The traditional method involves integrating, \( A = \displaystyle \int_0^1 2\pi {\color{red}y}\, dL \), which becomes \( A = \displaystyle \int_0^1 2\pi x^3 \sqrt{1+9x^4}\, dx\).

We can use Maxima to do this. The integral will evalute exactly as \(2\,\left( \frac{5\,\sqrt{10}}{27}-\frac{1}{54}\right) \,\pi \), but you may also wish a floating point approximation using the float(%) command.

```
integrate(2*%pi*x^3*sqrt(1+9*x^4),x,0,1);
float(%);
```

Or you could just use romberg() in the first place to get 3.563121122344691. the same answer we got with the theorem of Pappus.

Note that if you created the moment function M(t) previously, then you could have just done this (although you would not get the exact answer since you're using the romberg() command:

` M(2*%pi*x^3);`

Rotations are pretty straight-forward when rotated about either the x-axis or the y-axis. They're not too bad when rotated about other vertical or horizontal lines, either. For example, if you want to rotate about the vertical line \( x = 5 \), then the radius of rotation is \( r = | \bar x- 5 |\). This gives | 0.60864884735005 - 5 | = 4.391351153. Then the surface area is \( A = 2 \pi r L = 2 \pi (4.391351153 )(1.547866066810343) = 42.70821443 \).

Checking using the formulas given in the book, an integral would be \( A = \displaystyle \int_0^1 2\pi(5-x) \sqrt {1+9x^4}\, dx \).

`M(2*%pi*(5-x));`

Notice that we picked (5-*x*) rather than (*x*-5) since 5 is on the right and *x* is on the left (since \( 0 \le x \le 1 \)).

If the line is not horizontal or vertical, you need another formula. The distance between a point \( (x_0, y_0) \) and a line \( Ax + By + C = 0 \) is \( d = \displaystyle \frac{|Ax_0 + By_0 + C|}{\sqrt{A^2 + B^2}} \). So, let's say that you wanted to find the surface area when the curve is rotated about the line \( 3x + 2y = 9 \). The radius is the distance from the centroid to the line, which is \( r = \displaystyle \frac{|3(0.60864884735005) + 2(3663678347991)-9|}{\sqrt{3^2 + 2^2}} = 1.786500120573862 \). That makes the surface area \( A = 2 \pi r L = 2 \pi (1.786500120573862)(1.547866066810343) = 17.37465931794665 \).

The formulas for the centroid of a region are similar to those for finding the area of the region: \(A = \displaystyle \int_{left}^{right} ( top - bottom ) \, dx \) or \( A= \displaystyle \int_{bottom}^{top} ( right - left ) \, dy \). In fact, that's the basic integral and then you insert another factor into the integrand..

According to Pappus:

The volume of a solid generated by rotating a region about an axis (of rotation), which does not pass through the region, is the area of the region times distance traveled by the centroid of the region.

Consider the region bounded by \(y = 25-x^2 \), \( y = 3x+5\), \( x = 1 \), and \( x = 3 \).

The area integral would be \( A = \displaystyle \int_1^3 \left [ (25-x^2 ) - (3x+5) \right ]\, dx\). The integrand is a polynomial, so we shouldn't have to resort to romberg() to get numeric approximations.

`M(t):=integrate(t*((25-x^2)-(3*x+5)),x,1,3)$`

Finding the area, the x-coordinate of the centroid, the volume of rotation when rotated about the y-axis (using cylindrical shells), and the volume of rotation when rotated about the x-axis (using washers) are pretty straight forward.

- \( A = \displaystyle \int_1^3 \left [ (25-x^2 ) - (3x+5) \right ]\, dx\)
- \( \bar x = \displaystyle \frac 1 A \int_1^3 {\color{blue}x} \left [ (25-x^2 ) - (3x+5) \right ]\, dx\)
- \( \bar y = \displaystyle \frac 1 A \int_1^3 {\color{red}y} \left [ (25-x^2 ) - (3x+5) \right ]\, dx\). This one won't work because of the
*y*. - \( V_y = \displaystyle \int_1^3 {\color{blue} 2 \pi x } \left [ (25-x^2 ) - (3x+5) \right ]\, dx\)
- \( V_x = \displaystyle \int_1^3 {\color{blue}\pi} \left [ (25-x^2 ) ^{\color{blue}2}- (3x+5)^{\color{blue}2} \right ]\, dx = \int_1^3 {\color{blue}\pi \left [ (25-x^2) + (3x+5) \right ] }\left [ (25-x^2 )- (3x+5) \right ]\, dx\). I've written it the second way in case you decide to use the moment function; the \( (25-x^2)-(3x+5) \) is already in the integral, so the part in blue, the \( \pi \left [ (25-x^2)+(3x+5) \right ] \) is what needs introduced into the integrand.

The problems come with anything that involves *y*. Cylindrical shells or washers provide for rotating about either axis and avoiding the *y*, but we need it to find the y-coordinate of the centroid.

There are two *y* values if you're integrating with respect to *x*, one for the top function and one for the bottom function. The solution is to replace *y* by the average of the two functions, \( {\color{red}y} = \displaystyle \frac{top+bottom}{2} \). In this particular example, that would be \( {\color{red}y} = \displaystyle \frac{(25-x^2)+(3x+5)}{2} \).

\(\begin{aligned} \bar y &= \frac 1 A \int_1^3 {\color{red}y} \left [ (25-x^2 ) - (3x+5) \right ]\, dx \\ &=\frac 1 A \int_1^3 {\color{blue} \frac 1 2 \left [ (25-x^2)+(3x+5) \right ] }\left [ (25-x^2 ) - (3x+5) \right ]\, dx \\ \end{aligned} \)

```
M(t):=integrate(t*((25-x^2)-(3*x+5)),x,1,3)$
A:M(1);
xbar:M(x)/A;
ybar:M(1/2*((25-x^2)+(3*x+5)))/A;
Vy:M(2*%pi*x);
Vx:M(%pi*((25-x^2)+(3*x+5)));
```