In spite of the usefulness of continuous-wave near-infrared spectroscopy (CW-NIRS) for noninvasive measurement of oxygenation of the brain and muscle, no theoretically derived algorithms for this technique have yet been presented, although an algorithm can be theoretically determined on the basis of diffusion. We derive the theoretical mean optical pathlength based on diffusion theory, and we develop linear and nonlinear algorithms for CW-NIRS. Both algorithms are validated by the results of experiments using a phantom consisting of Intralipid and hemoglobin solutions. An extra absorber is also used to examine the effects of background absorption in tissues, except for blood. The changes in concentrations of oxy- and deoxyhemoglobin, calculated using both algorithms, agree well with those obtained by experiments around an operating point determined by the optical pathlength. The results of the phantom experiments and theoretical analyses show that the nonlinear algorithm can be used in a wider range of variation in absorption than the linear algorithm. The results also suggest that if the operating point is inappropriately given, the accuracy of both algorithms is greatly reduced. The errors in actual measurements of muscle oxygenation using the linear and nonlinear algorithms are also estimated, assuming a variation of ±50% in blood volume, and are found to be less than 12 and 6%, respectively, if the operating point is set appropriately.