Moment of Inertia - Non uniform density

Hey, need a quick bit of help, Maths Physics end of year exam and I can't find how to calculate the moment of inertia of a non uniform bod thin rod.

I'll post the question here for reference -

1. A rod AB of length 3m has non-uniform density x  15 − 2xkg/m where x measures
distance (in m) from the end A of the rod.
a. Find the moment of inertia of the rod about an axis perpendicular to the rod through the end
A.
b. Use your result to find the kinetic energy of the rod when it is rotating about the given axis
with angular velocity 2rad / s.
c. Deduce the moment of inertia of the rod about an axis parallel to the given axis but passing
through the centre of mass of the rod.
[Use the result in question 1 above for the location of the centre of mass.]

Staff: Mentor

Hey, need a quick bit of help, Maths Physics end of year exam and I can't find how to calculate the moment of inertia of a non uniform bod thin rod.

I'll post the question here for reference -

1. A rod AB of length 3m has non-uniform density x  15 − 2xkg/m where x measures
distance (in m) from the end A of the rod.
a. Find the moment of inertia of the rod about an axis perpendicular to the rod through the end
A.
b. Use your result to find the kinetic energy of the rod when it is rotating about the given axis
with angular velocity 2rad / s.
c. Deduce the moment of inertia of the rod about an axis parallel to the given axis but passing
through the centre of mass of the rod.
[Use the result in question 1 above for the location of the centre of mass.]

but I really just need the formula,

Thanks tons!

2. Relevant equations

I = Sigma m.r^2 ?

3. The attempt at a solution

Around 3 A4 pages of pointlessness

Welcome to the PF. You will use an integration instead of the Sigma sum. Just break the rod up into little mass pieces dm, with a linear mass density, and a small length dx. Use the equation that you are given for the linear mass density (units are kg/m), and express the each little mass piece dm in terms of that density and the small length piece dx.

Then use the formula that you allude to with your "I = Sigma m.r^2", but use an integration over x, of dm*x^2. Does that help?