2011
Nov
03

How much does data weigh in flash memory?

An interesting article in the New York Times has been making the rounds of the internet lately. It talks about the tiny theoretical increase in weight of a Kindle when its memory is full as opposed to when it's empty. Since I've previously written about the weight of data on a magnetic hard drive, I couldn't resist taking a look at the equivalent effect for flash memory.

To begin with, we need to know a little about how flash memory works, and to do that, we need to know how transistors work. A transistor is just a tiny electrical switch. It has two contacts, the source and the drain, that are separated by a layer of material with an excess or lack of electrons. Normally this configuration blocks any current from flowing between the source and the drain. But when the right kind of voltage is applied to the separation layer, it removes the excess (or fills the lack) of electrons, allowing current to pass through. (For the record, I know I'm not doing justice to semiconductor physics here.)

As described in a pretty good article on Explain That Stuff!, and several other sources I've looked at, a flash memory cell is basically a transistor with an electron "trap," called the floating gate, attached. When the transistor turns on, some of the electrons in the current will tunnel through a thin insulating layer into the floating gate. In the simplest scheme, the presence of these electrons represent a bit set to 1, while their absence represents a bit set to 0.

Now, one of the simplest results of quantum mechanics is that a particle trapped in a finite region has a finite minimum (ground state) energy. Take an electron in a 3D infinite square well, for example; its minimum energy is

E = \frac{\hbar^2\pi^2}{2m}\biggl(\frac{1}{L_x^2} + \frac{1}{L_y^2} + \frac{1}{L_z^2}\biggr)

A flash memory cell acts kind of like an infinite square well. Typical cell sizes are on the order of \SI{100}{\nano\meter} or less, so the ground state energy is going to be something like

E = \frac{\hbar^2\pi^2}{2m}\biggl(3\times\frac{1}{(\SI{100}{\nano\meter})^2}\biggr) \approx \SI{1e-23}{J}

But that's just for one electron. Each cell contains \num{1e3}-\num{1e5} electrons when fully charged. Of course, we can't just multiply the energy for a single electron by the number of electrons, because the Pauli exclusion principle bumps most of the electrons up to higher energy quantum states. To get the real total energy of a large number of electrons in a box, you need to integrate over the Fermi sphere. I'll omit the details of the calculation and just quote the result:

E = \frac{3N\hbar^2}{10m}\biggl(\frac{3\pi^2 N}{V}\biggr)^{\frac{2}{3}}

For about thirty thousand electrons, using my earlier estimate of a \SI{100}{\nano\meter} cubic cell, I get E = \SI{1e-16}{J}. This applies to a single cell, and thus a single bit. It's pretty close to the estimate of \SI{1e-15}{J} for a single bit quoted by Prof. Kubiatowicz in the New York Times article. Multiplying this by half of a Kindle's memory capacity of 4 GB, I get \SI{200}{\nano\joule}. Then you can divide this by c^2 to convert it to an equivalent mass of \approx\SI{2e-21}{\gram}. It's a little off from the estimate quoted in the article, but then again, the math there doesn't quite check out — and still, it's within a few orders of magnitude, which is good enough for me considering how rough this whole calculation is.

2010
Jun
11

Decapitation: Energy or momentum?

http://scienceblogs.com/dotphysics/2010/06/collisions_kinetic_energy_or_m.php

Took the words right out of my mouth. Or right off my keyboard. Whatever. I'm just happy to see other people are considering the same questions.

But I've got a couple of things to add. First of all, kinetic energy can be easily related to momentum using the formula

K = \frac{p^2}{2m}

which tells you directly that an object with the same energy but larger mass will have a larger momentum.

Also, the big question: is it energy or momentum that gives a collision its decapitating power? My thought is that it actually depends on force. Think about this from the point of view of a particle in the neck. This particle doesn't "know" (as if a particle could "know" anything) how big the sheet of glass hitting it is; it doesn't "know" how much energy or momentum the glass has. The reason is that energy and momentum are what I'm going to call global properties, basically meaning that the total amount of them possessed by some object comes from contributions from all different pieces of the object. To measure a global property of the glass, you need to have access to the entire piece of glass. But a particle in the neck doesn't have that access; it only interacts with a few atoms on the edge, so those are the only ones that can influence it. This means that whatever happens to the neck must be determined by local properties, which can be measured at a point, without having access to the entire piece of glass. And the relevant local property is force. (Think about it: when you feel a force from something pushing on you, you can tell how strong the force is without knowing anything about the object exerting it.)

But of course there's a little more to it than that. The ability to cut through a neck doesn't just depend on the glass being able to exert enough force; it also requires sufficient force to be maintained across the full diameter of the neck. When the glass first hits the neck, it exerts some force on the neck, which cuts through the first layer of skin, but the neck also exerts the same amount of force on the glass, which slows it down. (Newton's third law) Since the glass is moving more slowly, it's going to exert less force on the next layer of skin. The further it goes through the neck, the slower the glass is moving and the less cutting force it exerts. In order to make a clean decapitation, this continual decrease in speed has to leave the glass moving fast enough to cut through a layer of skin after it's made it all the way through the rest of the neck.

I can even apply some math to this, although there's not quite enough information to make a precise calculation. Here's what I do know. The force F on the glass changes the glass's momentum according to Newton's second law, F = \ud{p}{t} (this is only in one dimension, so I don't need to make the variables vectors, but I do need to be careful with signs). Momentum is, of course, p = mv, and I can use that and the chain rule to write

F = m\ud{v}{t} = m\ud{v}{x}\ud{x}{t} = mv\ud{v}{x}

So I know how the force affects the glass's speed. That's just general Newtonian dynamics. What I don't know is how the speed affects the force. In other words, how much force does the neck exert on the pane of glass, as a function of their relative speed? If I knew that function, F(v), I could plug it in to the previous equation and solve the differential equation for v.

To show how that would work, I'm going to make up an example function F(v), completely out of thin air. Well, not completely out of thin air — I'm going to take the function from... thin air ;-) If you've read my previous posts, you may remember the equation for the aerodynamic drag force,

F = \frac{1}{2}CA\rho v^2

This is precisely the kind of equation we'd want: the force of resistance, as a function of speed, on a solid object moving through some stuff. Specifically, a fluid. Of course, a neck is hardly fluid-like, but this is just an example so it'll do the job. (You have a better idea?)

Glass cutting through a neck

In this situation A can be the cross-sectional area of the glass that is in contact with the neck, and \rho will be the volume mass density of neck material (that's mass per unit volume). But \rho depends on the full 3D position, so it's be easier to consider the product of \lambda = A\rho, which is the linear mass density along the direction that the glass moves — in other words, \lambda is the mass per unit x-distance that the glass cuts through. It's a function of only x, not the other coordinates.

If you combine the drag equation with the dynamic equation above it, you get

-\frac{1}{2}C\lambda v^2 = m_\text{glass}v\ud{v}{x}

The negative sign is necessary because the force points in the negative direction. This is a separable differential equation, so we can rearrange it to

-\frac{1}{2m_\text{glass}}C\lambda\udc x = \frac{\udc v}{v}

and integrate it to get

-\frac{1}{2m_\text{glass}}\int_0^L C(x)\lambda(x)\udc x = \ln v(L) - \ln v(0)

L is the total length of the neck that the glass cuts through. (Or you could make L be some distance partway through the neck, if you wanted to find the glass's speed there) I started writing C as C(x) to remind us that it varies with position, and same with \lambda(x). Now I can solve for v(L), the final speed, in terms of v(0), the known initial speed, and I get

v(L) = v(0)e^{-\int_0^L C(x)\lambda(x)\udc x/2m_\text{glass}}

So what does this have to say about the original question? Does a larger piece of glass with the same energy have the same decapitating power?

Well, there's no reason to expect this formula to be accurate, given all the unjustified assumptions that went into deriving it. But on the other hand, I'd expect that it would have some tenuous relation to reality. If you increase the mass of the neck (say, by making it denser, increasing \lambda(x)), the equation says the glass loses more speed, which makes sense. And if you increase the mass of the glass, the equation says it retains its speed better, which also makes sense.

Let's try this out with the Mythbusters' actual experiment. They tried to simulate the effect of the piece of glass Tory threw, with mass \unit{0.45}{\kilo\gram}, if it were moving at a speed of \unit{300}{\mileperhour}, or \unit{134}{\frac{\meter}{\second}}. According to the calculations they did on the show, that has an energy of \unit{4.04}{\kilo\joule}, and the mass required to reproduce that energy at \unit{80}{\mileperhour} is \unit{6.3}{\kilo\gram}. So we have two sets of parameters:

m_\text{glass} = \unit{0.45}{\kilo\gram},v(0) = \unit{134}{\frac{\meter}{\second}}

m_\text{glass} = \unit{6.3}{\kilo\gram},v(0) = \unit{36}{\frac{\meter}{\second}}

The quantity \int_0^L C(x)\lambda(x)\udc x is going to be the same in both cases. Let me call that M since it has the units of mass. If I plug in the parameters just listed, I get

v(L) = \unit{134}{\frac{\meter}{\second}}e^{-M/\unit{0.9}{\kilo\gram}}

v(L) = \unit{36}{\frac{\meter}{\second}}e^{-M/\unit{12.6}{\kilo\gram}}

Hmm, so this definitely depends on M. Which I don't know. But if you think about it, M is basically the mass of neck that the glass cuts through, with some scale factor (related to the "drag coefficient" C) that's probably between \frac{1}{10} and 10. (I don't actually know, I'm just guessing here) A window-thin piece of neck probably has a mass of \unit{100}{\gram} or less, which means that M is likely less than \unit{1}{\kilo\gram}. Now look at this plot of v(L) for various values of M in that range:

Plot of final velocity versus M

The top curve is for the smaller piece of glass, the one Tory threw, and the bottom line is for the larger piece they put on the truck. Clearly, for this range of values for M, the smaller piece has a much higher final velocity, and that indicates a much higher decapitating power.

2010
May
23

Waterslide Wipeout

Like everyone else, I feel a need to analyze the giant water slide in the latest Mythbusters episode. But honestly, there isn't much left to say. The original video has been around for a while and everybody else who does this kind of analysis has already had the chance to do it. Example 1; example 2 (okay, so I'm only linking to one blog, but there must be more).

I guess I might as well do the obvious calculation, but I'll use the Mythbusters' parameters instead of those from the original video (which are unknown). The slide starts with a downward ramp \unit{165}{\foot} long at a \unit{24}{\degree} slope, which then curves upward to a \unit{30}{\degree} launch ramp that terminates \unit{12}{\foot} above the surface of the lake. They didn't say how long the launch ramp is, but I can work without that information. I'll be trying to calculate two quantities mentioned on the show: how far each Mythbuster flies from the end of the ramp, and his maximum speed.

Diagram of the waterslide

(here's a full-size version)

There are two parts to this problem:

  1. The slide
  2. The flight

The first part is an energy problem. All energy problems can be solved in the same way, starting with the work-energy theorem

W_\text{ext} = E_f - E_i

and plugging in, term by term.

W_\text{ext} is the work done by external, nonconservative forces, like friction. The friction is proportional to the normal force, which (for most of the slide) is in turn equal to the component of gravity acting perpendicular to the surface. So

F_f = \mu_k F_N = \mu_k m g \cos\theta_1

where \theta_1 is going to be the \unit{24}{\degree} angle of the acceleration ramp. This frictional force acts antiparallel to the motion over a distance of d\equiv\unit{165}{\foot} (plus a little correction that I'll leave for later), so we get

W_\text{ext} = \vec{F}_f\cdot\Delta\vec{x} = -\mu_k m g d \cos\theta_1

The next term, E_f, is the final energy, at the end of the slide when the person flies off. This is a combination of gravitational potential energy, U = mgh, and kinetic energy, \frac{1}{2}mv^2. Accordingly, I'll write it

E_f = mgh_1 + \frac{1}{2}mv^2

using h_1 to represent the height of the launch point above the lowest part of the ramp.

Finally, the initial energy is purely gravitational. The height is a lot higher this time; specifically,

E_i = mgd\sin\theta_1

Putting it all together,

-\mu_k mgd\cos\theta_1 = mgh_1 + \frac{1}{2}mv^2 - mgd\sin\theta_1

The first thing to notice is that mass cancels out, so it shouldn't make a difference how heavy you are. In the show, Jamie flew 2 feet further than Adam, but I suspect that that was just a fluke, not a statistically significant result. I get

v^2 = 2[gd(\sin\theta_1 - \mu_k\cos\theta_1) - gh_1]

By the way, this factor of \sin\theta - \mu_k\cos\theta seems to be fairly common — you can often expect to see it when doing a problem that involves a ramp with friction.

Now it's time to move on to part 2, which is a projectile motion problem. I'll use the same height reference as before, the bottom of the curve of the ramp. So we're launching an object from height h_1 at an angle \theta_2 to a surface at height -h_2; how far does it travel?

First step: Find the time it takes to hit the water.

y = y_0 + v_0 t + \frac{1}{2}at^2

Plugging in the relevant expressions, we get

-h_2 = h_1 + v\sin\theta_2 t - \frac{1}{2}gt^2

which has the solution

t = -\frac{1}{g}\Bigl(-v\sin\theta_2 \pm \sqrt{v^2\sin^2\theta_2 + 2g(h_1 + h_2)}\Bigr)

Second step: multiply that time by horizontal velocity to get horizontal distance. This one is easy; the horizontal velocity is v\cos\theta_2 so we get

x = \frac{v\cos\theta_2}{g}\Bigl(v\sin\theta_2 \pm \sqrt{v^2\sin^2\theta_2 + 2g(h_1 + h_2)}\Bigr)

Given that the solution for the previous part came out in terms of v^2 (because I dislike ugly square root signs), here's a useful way to rewrite that:

x = \frac{v^2\sin\theta_2\cos\theta_2}{g} \pm \frac{1}{g}\sqrt{v^2\bigl(v^2\sin^2\theta_2 + 2g(h_1 + h_2)\bigr)\cos^2\theta_2}

At this point we could substitute in v^2 from before and get a symbolic expression, but it's getting pretty complicated. Probably better to plug in numbers.

First, a recap of the numeric values involved. I'm taking the length of the slide from the top down to its lowest point to be d = \unit{165}{\foot}, the height of the end of the slide above that lowest point to be h_1 = \unit{6}{\foot}, the height of the water below the lowest point of the slide to be h_2 = \unit{6}{\foot}, and the angles of the slide and the launch ramp respectively to be \theta_1 = \unit{24}{\degree} and \theta_2 = \unit{30}{\degree}. Plugging all these in to the expression for velocity, I get

\unit{370}{\frac{\meter^2}{\second^2}} - \unit{900}{\frac{\meter^2}{\second^2}}\mu_k

Hmm, well that's a problem. Or is it? We don't know the coefficient of friction, but we do know the number this is supposed to work out to, namely (\unit{30}{\mileperhour})^2. The value \unit{30}{\mileperhour}, was given on the show as the maximum speed reached by both Jamie and Adam as they went down the slide. Technically my expression for velocity is for the speed at the end of the launch ramp, which will be a little slower than the maximum speed, but I've made enough approximations that it probably doesn't make a big difference. So I'll go ahead and plug in v = \unit{30}{\mileperhour} and use Mathematica to solve for the coefficient of friction, \mu_k. It comes out to be \mu_k = 0.2. Seems reasonable.

Let's try this another way, though. Again using Mathematica, I can substitute my expression for v^2 into the expression for x. Both Jamie and Adam flew about \unit{70}{\foot} horizontally, so that's my value for x. Then I can plug in all the other distances and angles taken from the show and get another equation for \mu_k:

\unit{21.3}{\meter} = \unit{16.1}{\meter} + \unit{39.8}{\meter}\bigl(\sqrt{(\mu_k - 0.72)(\mu_k - 0.41)} - \mu_k\bigr)

That one takes a bit more algebra — of course, I'll just get Mathematica to do it ;-) The solution works out to... \mu_k = 0.2! The fact that these two values are the same is, at least, an encouraging sign that this calculation actually corresponds to reality.

Here's something else we can try: predicting (actually "postdicting") the distance covered on each of the earlier, shorter slides. Everything (including the coefficient of friction) is the same as before, except for the distance d, which was first a half, then three quarters, of the total length. So if I plug in d = \frac{1}{2}\times\unit{165}{\foot}, I get

v = \unit{8.6}{\frac{\meter}{\second}} = \unit{19}{\mileperhour}

x = \unit{11}{\meter} = \unit{35}{\foot}

Not so great, considering that the actual distance Adam flew on that run was just 4 feet. But the corrections I alluded to earlier might help that out a bit... that's a story for another post, though. What about d = \frac{3}{4}\times\unit{165}{\foot}?

v = \unit{11}{\frac{\meter}{\second}} = \unit{25}{\mileperhour}

x = \unit{16}{\meter} = \unit{52}{\foot}

They didn't give measurements for these runs on the show, but from the video I estimate that Adam flew about 40 feet. Still not that great, but we're getting closer.

Even though I know this model doesn't quite work, I've got one last set of numbers to run. How high would the ramp have to be to achieve the hypothetical \unit{115}{\foot} flight in the video? Since I already had the Mathematical machinery set up to compute flight distance for a given ramp length, I decided to do this one by trial and error, plugging in different values for d to narrow in on the one that yields a distance of \unit{115}{\foot}. It works out to \unit{85}{\meter}, or \unit{280}{\foot}, which is really long. But think about this: for shorter runs than the Mythbusters' full-length slide, my model overestimates the distance traveled. Perhaps for longer runs, it'll underestimate the distance traveled, which means that in reality, maybe a shorter slide would do the job. And in fact, if you look at the data points for the slides on the show — keeping in mind that it's dangerous to extrapolate from only three points — they do seem to fall in a line, and that line suggests that you might only need a \unit{220}{\foot} slide to achieve a \unit{115}{\foot} flight.

Graph of flight distance vs. slide length

Interesting, isn't it?

2010
Apr
06

Shockwave reflection

The latest episode of Mythbusters features a myth with a deep physical explanation... no pun intended! Well, maybe. Anyway, the myth is that by diving under the water, you can escape injury from an explosion occurring above the surface. Adam and Jamie tried to solve this puzzle by experiment (what else), and their results seemed to show that the myth might actually be true, but I want to look at it from the theoretical standpoint: why might being underwater protect you from an explosion?

There is actually a not-too-obscure answer to this puzzle, and it has to do with refraction and reflection. These are phenomena that occur when a wave (of any sort — light, sound, or whatever) crosses a boundary between two media in which it has different speeds. Part of the wave bounces back (that's reflection) and part of it continues through, but in a different direction (that's refraction). Exactly how much of the wave's power is reflected and how much is transmitted through, as well as the new direction of the transmitted part, depends on the angle of the incoming wave with respect to the surface, and also on the relative speed of the wave in the two materials.

Reflection and refraction of waves

Reflection and refraction are most often discussed in connection with light. Lenses, for example, work by refracting incoming light, since light travels slower in glass (or plastic) than in air. Because the surface of the lens is curved, it bends different light rays in different locations by different amounts, and this can be used to focus an image. But the same thing happens with pressure waves, like sound waves and explosive shockwaves, at the surface of a lake, because pressure waves travel faster in water than they do in air. It stands to reason, then, that part of the energy in a blast wave would be reflected off the surface of the lake, reducing the energy available to damage anyone (or anything) below the water.

Unfortunately, calculating how much energy is reflected and how much is transmitted when a shock wave hits water turns out to be a very involved problem, not something that can be learned and solved in a week ;-) Still, there are some qualitative things I can say about the process. Consider what happens to a pressure wave in air when it hits a boundary, such as a wall: the wall will vibrate a bit, but the wave mostly just bounces back. You'd expect that a similar sort of thing would happen if the wave hits a water surface instead, since compared to air, water is very "hard" — technically speaking, it has a very low compressibility. This is related to a material property called the bulk modulus, which basically measures how much the material resists being squashed (compressed). The bulk modulus of water is about 10000 times larger than that of air, so the increase in pressure applied by a wave will have a relatively minor effect on the water. It'll have a much greater effect on the surrounding air, which means that that's where most of the energy goes: back into the air.

If pressure waves don't affect water that much, though, why was there such a huge splash every time the Mythbusters set off one of their explosions? The amount of energy in an explosion shockwave is so large that even "relatively minor" can be enough to throw a lot of water around! Since air is transparent, most of the wave's effect on the air goes unnoticed.

2009
Jun
10

Sonic Black Holes

Here's something interesting that came up on Slashdot today: scientists at the Israel Institute of Technology report having created an "acoustic black hole", a region from which no sound waves can escape, just as a normal black hole is a region from which no light waves can escape.

How did they do it? Well, whenever sound travels through a medium, it does so at a characteristic speed — about \unit{343}{\frac{\meter}{\second}} in air, for example. That speed is relative to the medium, though, so if you can get the medium to move through your lab at a faster speed, the sound waves won't be able to propagate fast enough to move against it (relative to the lab). If you had a wind tunnel blowing air to the right at \unit{400}{\frac{\meter}{\second}}, the air would carry along all sound waves traveling through it, even those emitted in the leftward direction. Any sound waves produced at the right end of the tunnel would be stuck there — in effect, it's a one-dimensional acoustic black hole, with an event horizon at the point (surface, really) where the air accelerates past the speed of sound as it's drawn into the tunnel.

Building a supersonic wind tunnel is no easy task, though — and even if you did it, you'd run into problems with turbulence messing up the propagation of sound waves through the air. The acoustic black hole actually reported was created in a Bose–Einstein condensate, a special low-temperature state, of rubidium. This has two advantages: first, you don't have to deal with turbulence, and also, the speed of sound is much slower, typically less than \unit{1}{\frac{\milli\meter}{\second}} according to the paper. Although creating and stabilizing a Bose-Einstein condensate in the first place is no easy matter, it's a lot easier to control than a wind tunnel.

The reason everyone is so excited about this is that it paves the way for experimental detection of Hawking radiation. In real black holes, Hawking radiation occurs when a particle and an antiparticle spring into existence near the event horizon of a black hole; one of them falls in, and the other is "radiated" away. But in an acoustic black hole, instead of particles and antiparticles, you can get sound waves ("phonons") radiating in opposite directions, one heading into the acoustic black hole and one heading away. Here's how that works: the energy of a phonon, relative to the medium (the air or BEC), is given by

E = pc

where p is the momentum carried by the wave and c is the speed of sound (it's not a coincidence that this looks just like the formula for the energy of a photon). But when that whole medium is moving with a speed v relative to your lab, you see sound moving at the speed c - v, so you would calculate the energy as

E = p(c - v)

So if two phonons are created with the same momentum, but on opposite sides of the event horizon, the one inside the horizon has v > c, giving it negative energy, and the other has v < c, giving it positive energy. And for waves created in the right positions, the energies add up to zero, meaning that these waves can be created at virtually no cost to the universe.

Why is Hawking radiation so special? Nearly all physicists are very confident that it exists, but the fact remains that nobody has ever directly observed Hawking radiation, simply because nobody has been able to get up close to an event horizon to study it. So seeing the stuff for the first time will be an exciting moment in the history of physics. Plus, when you can create small, easily controllable systems that mimic black holes, you could potentially discover all sorts of other cool things that could be happening out in space.

Probably of more interest to the public is the way Hawking radiation is relevant to the whole LHC "doomsday" myth. There's been a lot of hype about the idea that the LHC could produce a black hole which could destroy the world, and Hawking radiation is the favorite explanation for why that can't happen. Simply put, any black hole that might be produced on Earth would evaporate due to Hawking radiation long before anything could fall into it. (Of course, there's also the fact that the LHC just reproduces processes that occur in the upper atmosphere. So even if Hawking radiation isn't going to save us from black holes, something else will.)

2009
Apr
17

How much does data weigh?

An interesting question came up on StackOverflow: does a hard drive weigh more when it's full than when it's empty? Or more generally, does the weight of a hard drive change depending on how much (and what) data is stored in it?

First of all, as far as anyone in the IT industry is concerned, the answer is no. Any change in mass that would result from magnetic alignment is far too small to be measured by even the most sensitive scales in the world — we're talking about a difference of something like 10^{-14} grams.

Now, how did I get that number?

Let's start from the beginning. Every atom has a property called the magnetic dipole moment, which means it acts like a tiny bar magnet, with a north pole and a south pole. In a ferromagnetic material, the type that's used to store data in a magnetic hard drive, adjacent atoms tend to align parallel to each other, so that their north poles all point in the same direction. This leads to the formation of magnetic domains, small groups of atoms which are all aligned; each domain acts like one tiny bar magnet. To use a simplified model, a magnetic domain whose north pole points toward the reading head represents a set bit (1), and a group of atoms whose spins point away from the head represents an unset bit (0). Recent drives use GMR (giant magnetoresistance) instead, which basically changes the electrical resistance of a chunk of the hard drive depending on whether the spins in two layers are aligned or antialigned — but still, the data is based on the alignment of magnets.

Magnets have differing amounts of energy depending on whether they're aligned or antialigned. According to the laws of physics, the energy of a pair of magnetic dipoles is

E = -\frac{\mu_0}{4\pi}\frac{\mu_1 \mu_2 \cos\theta}{r^3}

that is, the product of the two magnetic dipole moments, times the cosine of the angle between them (which is +1 for parallel alignment or -1 for antiparallel alignment), divided by the cube of the distance between them.

Most people know that according to Einstein's theory of relativity, energy corresponds to mass according to the equation E = m c^2

Well... technically it's more complicated than that, but this equation is good enough for us. The important point is that just like mass, energy responds ("couples") to gravity — that is, it has a weight. So we can take the energy difference between the two possible alignments of the magnets and divide it by c^2 to get the equivalent mass.

Back to those numbers I mentioned earlier. Suppose a hard drive contains 10 grams of data-storing cobalt, and the dipole moment of each atom is contributed by a single free electron, which means it's equal to a constant called the Bohr magneton. (I make no claim that these assumptions are accurate, but they should be close to the right order of magnitude) There would be around 10^{23} electrons, but in a 1TB drive these group themselves into about 10^{12} domains spread over a total platter area of let's say \SI{400}{cm^2}, which puts the average separation distance at around a tenth of a micrometer. Then assuming each domain interacts mainly with its 4 immediate neighbors, the total energy is around \SI{-5}{J} if every domain is aligned in the same direction (that's like a drive containing all zeros) or \SI{5}{J} if the domains are antialigned. Dividing the difference by c^2 we get an effective "mass" difference around 10^{-14} grams. Given that a full hard drive weighs on the order of a kilogram, we're talking about one part in 10^{17} (that's 1 in 100 000 000 000 000 000)! This is typical of situations where energy is treated as a mass: because of the factor of c^2, a moderate amount of energy corresponds to an incredibly tiny mass.