# Calculating the coefficient of thermal expansion in liquid

I am trying to write a matlab function that calculates the coefficient of thermal expansion of water from a given temperature. From what I understand the thermal expansion coefficient is calculated as the degree of expansion divided by the change in temperature, expressing the tendency of a fluid to change in volume with a change in temperature.

The following code calculates this in matlab:

T = 20; % initial temperature
dT = 0.001; % change in temperature °C
V = 1; % volume m^3

rho1 = waterDensity(T); % density of temperature
rho2 = waterDensity(T+dT);% density of second temperature

V2 = rho1./rho2;
alpha = (V2-V)/dT; % coefficient of thermal expansion in deg C-1


where waterDensity is an external function that calculates the density of water in kgm-3 from a given temperature. Here, I'm having trouble making sense of this, mostly I don't understand why we need the line that starts with V2. I would have though that if mass is conserved the volume is given by the density so alpha should be calculated by the change in density divided by the change in temperature i.e.

alpha = (rho - rho1) ./ dT


Could anyone explain to me why this isn't the case.

I know that the first method works because it gives the same result as:

alpha = 1.6e-5 + 9.6e-6 .* T;


which is commonly used in the literature.

• Hi user. I think you know how we use our homework tag. You can have a look at the definition before asking me, "Why have you retagged this to homework?" ;-) May 2 '13 at 15:24
• 'guide the asker to the answer rather than giving it away outright'.
– Emma
May 2 '13 at 17:30

Are you sure that the first block of code is correct? V2 should have been multiplied by V. You get correct values here only because you assumed V=1.

No, the difference in volumes isn't equal (or even in linear proportion) to difference in densities because they have an inverse relation. In terms of densities you have: $\alpha = {m (\frac 1 \rho - \frac 1 \rho_1) \over dT}$

• This works: alpha = rho2.*(((1./rho2) - (1./rho1))./dT); Does that make sense?
– Emma
May 3 '13 at 6:10
• No, this one works because you get V=1 again so mass is equal to density. For volumes other than unity it's incorrect.