If different types of quarks have different masses, then why are protons and neutrons said to have the same mass, when they have different compositions of quarks?
Protons and neutrons do not have the same mass. Their masses are quite close, but they are noticeably different. For some purposes it is okay to equate the neutron and proton mass, but it's just an approximation. Also, neutrons decay into a proton, an electron and an antineutrino. For that to happen the neutron must be heavier than the proton. Because the neutron is only a little heavier than the proton the decay takes a long time. For isolated, or "free" neutrons, the time is ~16.7 minutes. This is the mean, or average, lifetime for a neutron to turn into a proton. When neutrons and protons are mixed together to form a nucleus the neutrons do not decay as long as they stay inside the nucleus. We would not be here nor would the rest of the universe if neutrons could decay just as easily inside a nucleus as they could outside! This is the case because the binding energy of a proton or neutron in a nucleus is about 8 MeV (Million Electron Volts) on average and that's bigger than the proton-neutron mass difference. This makes the neutron stable inside a nucleus and therefore the universe is saved from a very early end.
The proton has a mass in energy units of 938.256 MeV while the neutron is 939.550 MeV. Now, how about the quarks? The proton and neutron are each made from three quarks. A proton is made up of two Up quarks and a Down quark while a neutron is made from two Down quarks and an Up quark. If protons and neutrons only had quarks in them it would be easy algebra to get the quark masses. However, there is a family of lighter particles called Pions that are made from pairs of quarks. They are made from pairs of Up and Down quarks. They have masses that are a lot smaller than two thirds of the proton or neutron mass so determining the masses of the quarks isn't easy!
Pions have masses of 139.6 MeV for Pi+ or Pi- and 134.975 MeV for the Pi0 or Pi zero (neutral). One of the reasons that we can't just use simple algebra to get the quark masses is that the quarks are bound so tightly together. They are so tightly bound that if you try to pull them apart you just make more particles and never (not yet anyway) get a loose quark. The quarks lose much of their mass in binding energy. That is, the composite particle weighs less than the separate quarks would. We can estimate the masses of the quarks from the mass differences of the elementary particles, but it's just a rough estimate. For example, Kaons are made from an Up (or Down) quark and a Strange quark. Kaons have masses of 497 MeV so the mass difference between a Strange quark and an Up (or Down) is approximately the same as the Kaon-Pion mass difference (497 - 139 = 358). We also have a particle called a Lambda which is made from three quarks - one of which is Strange, and the Sigma, which also has one Strange quark. The Sigma mass minus the proton mass is 251 MeV while the Lambda mass minus the proton mass is 177 MeV. These simple differences tell us that the Strange quark is heavier than the Up (or Down) by about 358 MeV (or 251 or 177). As I said, this is only approximate. This arithmetic is only useful if you are comfortable with 358 ≈ 251 ≈ 177. For some purposes the crude equality above is actually useful and guides our understanding. We could even start to form a simple picture of what's going on from all this. We can also estimate the quark masses from the lightest mesons that are made up of pairs of quarks. There is a meson called the Phi that is composed of two Strange quarks. It has a mass of 1019 MeV. So a Strange quark is about ~510 MeV. The next one up is called the J/Psi particle and its 3,100 MeV and is made from a pair of Charmed quarks. These guys have to be ~1500 MeV each. Higher still is the Upsilon at about 9,600 MeV and its a Bottom quark pair so the Bottom quark is maybe 4,800 MeV! Recently, evidence for the Top quark was found and its approximate mass is 91,000 MeV! We would know that the Up quark has approximately the same mass as the Down quark because the neutron-proton mass difference is small and because the pion mass differences are all small. We could further suppose that the Strange quark could be 358 MeV heavier than the Up or the Down quarks based on the Kaon-Pion mass difference. We could also set limits on the Up (Down) mass. The Up (Down) quark could be as heavy as the proton mass divided by three. That would make the Up (Down) around 310 MeV on the high end. So where are we with the quark masses by this crude method:
Up ≈ Down ≈ 300 MeV
Strange ≈ 510 MeV
Charmed ≈ 1,500 MeV
Bottom ≈ 4,800 MeV
Top ≈ 91,000 MeV
A good reference on the web for more info on quarks and particles is to be found at: Quarks and Particles.
If we had a theory that could predict the binding energy of the common particles then we could calculate the quark masses. If we could produce free quarks we could simply measure their masses just like we have measured the proton, the electron, the neutron and other particles to very high accuracy. As I said before, free quarks have not been found so we must derive their properties by a mix of theory and experiments. The most successful theory (so far) of the particles is called the Standard Model. It has had great success for the last ~30 years, but it does not predict why the quarks have the apparent masses that they do! A possible mechanism that extends the Standard Model and accounts for the origin of the masses of the quarks is called the Higgs Mechanism. This is one of the most hotly pursued subjects of experimental physics today. There have been some tantalizing, but not quite convincing, hints of the first appearance of the Higgs at a laboratory called Centre Europeen de Recherche Nucleaire (CERN) in Switzerland. The search at CERN was halted to upgrade the lab and prepare for a more powerful search. Meanwhile, the search will continue for the next few years at a laboratory called Fermi National Accelerator Laboratory (FNAL) located in Illinois.
Perhaps one of you will someday work at CERN, Fermilab, or another lab and help make the big discovery!
Paul Brindza, Experimental Hall A Design Leader (Other answers by Paul Brindza)