# Centroid calculation using integrals

arhzz
Homework Statement:
Find xs and ys
Relevant Equations:
Integration
Hello!

Im given this function ## f:[-\pi/2,1] -> [0,1]## with f(x) = 1-x for x (0,1] and f(x) = cos(x) for x ##[-\pi/2,0] ##

And im susposed to find the centroid of this function so xs and ys.

For that I am given these 2 equations ( I found them in the notes)

## x_s =\frac{1}{A} \int_{a}^{b} f(x) x dx ## and ##y_s =\frac{1}{A} \int_{a}^{b} \frac{f(x)}{2}*f(x) dx##

Now to calculate A I found this formula ## A = \int_{a}^{b} f(x) dx ##

Okay so now looking at my problem specificly I have 2 diffrent values for the function depending on where it is. So I calculated A1 and A2; one for 1-x with the integral bounderies going from 0 to 1 and A2 for cos(x) with integral bounderies being -pi/2 and 1

I get ## A_1= \frac{1}{2} ## and ##A_2 = 1 ## Think that should be correct. Now since I have 2 A's (A should be the surface) I went ahead and caluclated using the formulas I posted above xs1 and xs2. For xs1 I used A1 and the same integral bounderies (0 to 1); for xs2 I used A2 and -pi/2 to 1

I get ##xs_1 = \frac{1}{3} ## and ##xs_2 = 1 - \frac{\pi}{2} ## Okay now to get a final xs I tried adding xs1 and xs2 together

After doing that i get this ##x_s =\frac{8-3\pi}{6} ## for xs. The solution says it should be ##xs = \frac{7-3\pi}{9} ##

I have rechecked all of my integrals and they should be correct,so im making a mistake somewhere else.I am not to sure what to do when I have 2 xs's, can i just add them together or not? Am i choosing the integral bounderies correctly or not?

Last edited:

Mentor
Im given this function ## f:[-\pi/2,1] -> [0,1]## with f(x) = 1-x for x (0,1] and f(x) = cos(x) for x ##[-\pi/2,1] ##
For the above function, I think that for the 2nd part of your function the definition should be ##f(x) = \cos(x)## for ##x \in [\frac{-\pi}2, 0]##.

I'll take a look at the rest of your work and reply on it later.

Mentor
Okay so now looking at my problem specificly I have 2 diffrent values for the function depending on where it is. So I calculated A1 and A2; one for 1-x with the integral bounderies going from 0 to 1 and A2 for cos(x) with integral bounderies being -pi/2 and 1
This is the source of your problems. If I am correct in what I wrote in the previous post, the interval for the f(x) = cos(x) part should be ##[-\pi/2, 0]##, not ##[\pi/2, 1]##. With the intervals you wrote, you'll get two different function values on the interval [0, 1], so you'll get the wrong values for the area beneath the cos(x) part as well as the moment about the y-axis, which you're calling xs.
I get ## A_1= \frac{1}{2} ## and ##A_2 = 1 ## Think that should be correct.
I get the same values for the two areas. Was this your integral for ##A_2##: ##\int_{-\pi/2}^0~\cos(x)dx##? If so, you are using the correct interval; namely ##[-\pi/2, 0]##.

You don't show the work you did for what you're calling xs (the moment about the y-axis). If you use the wrong interval for this integral, you'll get a wrong value.

Also for what you're calling ys, the moment about the x-axis, you'll need to use ##\cos^{-1}(x)## in the integrand, with the limits of integration being 0 and 1.

arhzz
This is the source of your problems. If I am correct in what I wrote in the previous post, the interval for the f(x) = cos(x) part should be ##[-\pi/2, 0]##, not ##[\pi/2, 1]##. With the intervals you wrote, you'll get two different function values on the interval [0, 1], so you'll get the wrong values for the area beneath the cos(x) part as well as the moment about the y-axis, which you're calling xs.

I get the same values for the two areas. Was this your integral for ##A_2##: ##\int_{-\pi/2}^0~\cos(x)dx##? If so, you are using the correct interval; namely ##[-\pi/2, 0]##.

You don't show the work you did for what you're calling xs (the moment about the y-axis). If you use the wrong interval for this integral, you'll get a wrong value.

Also for what you're calling ys, the moment about the x-axis, you'll need to use ##\cos^{-1}(x)## in the integrand, with the limits of integration being 0 and 1.
Oh I just checked I made a mistake in the original post. The interval you posted is correct and that is the one I used; A2 you just typed in. I will edit my post.

Although I typed it in the forum wrong I calculated with the right intervals; hence you get the same area under the curve. The rest what I did is I just pluged in the formula. I can post it in detail if it will help.

Mentor
The rest what I did is I just pluged in the formula. I can post it in detail if it will help.
Yes, please post your integrals for xs and ys. If you click on the integral I wrote you can see the Tex that I wrote for it.

arhzz
Okay here we go

$$x_s1 = \frac{1}{A1} \int_{0}^{1} xf(x)dx$$ With plug in values $$x_s1 = \frac{1}{1/2} \int_{0}^{1} (1-x) * x dx$$

Multiply the brackets out and get rid of the double fraction $$2 * \int_{0}^{1} x^2 - x dx$$ Now solve the Integral, it should be only the power rule so we get $$2 * ( \frac{x^2}{2} - \frac{x^3}{3})$$ And I dont know how to do it in LaTeX but evalute the brackets at 1 and 0. Now I put the bracket term on a common denominator and get this $$2*(\frac{3x^2-2x^3}{6})$$ So now we have to plug in 1 into x and subtract that from plugging 0 into x. If we plug 1 into this we get 1/6, if we plug 0 we get 0 hence we are left with. $$2 * \frac{1}{6}$$ and that is 1/3.

Okay for xs2 =$$1 * \int_{-pi/2}^{0} xcos(x) dx$$ Use partiall integration to solve the integral; I get $$1* (xsin(x)+cos(x))$$ and evaluate at -pi/2 and 0. Plug in first 0 than -pi/2 and subract them from each other.We should get $$1*(1-\frac{pi}{2} )$$.

This is how I did it

Mentor
That doesn't look right to me.

The moment about the y-axis, which you have separated into s1 and s2 has to be done as a single quantity. You can't do them separately.

This is what you need. $$\overline x = \frac{M_{y, 1} + M_{y, 2}}{A_1 + A_2} = \frac{\int_{-\pi/2}^0~x\cos(x)dx + \int_0^1 ~x(1 - x)dx}{A_1 + A_2}$$

Your values for the two integrals look ok to me, but you can't calculate the two parts of this moment separately.

The value I get for ##\overline x = \frac{M_y}{A_1}##, the x-coordinate of the centroid, is ##1 - \frac \pi 3##. I don't guarantee that I haven't made any mistakes.

Calculating ##M_x## will be a bit harder, but you need it to get the other coordinate of the centroid, ##\overline y##.

arhzz
arhzz
That doesn't look right to me.

The moment about the y-axis, which you have separated into s1 and s2 has to be done as a single quantity. You can't do them separately.

This is what you need. $$\overline x = \frac{M_{y, 1} + M_{y, 2}}{A_1 + A_2} = \frac{\int_{-\pi/2}^0~x\cos(x)dx + \int_0^1 ~x(1 - x)dx}{A_1 + A_2}$$

Your values for the two integrals look ok to me, but you can't calculate the two parts of this moment separately.

The value I get for ##\overline x = \frac{M_y}{A_1}##, the x-coordinate of the centroid, is ##1 - \frac \pi 3##. I don't guarantee that I haven't made any mistakes.

Calculating ##M_x## will be a bit harder, but you need it to get the other coordinate of the centroid, ##\overline y##.
Ahh okay that makes sence.See I did not know this formula existed, and I knew I was calculating the integrals right. So if I understood you correctly this will give me the value of my xs? So for ys I need to the same but solve a trickier integral?

Mentor
Ahh okay that makes sence.See I did not know this formula existed, and I knew I was calculating the integrals right. So if I understood you correctly this will give me the value of my xs? So for ys I need to the same but solve a trickier integral?
Yes.

arhzz
arhzz
Okay I finally got around to revisiting this.And you are right,the formula was wrong. Using the formula you gave me the right result (the result I was not been able to find in post #1). Thank you for your great help as always!