Gastric acid
The main constituent of gastric acid is hydrochloric acid which is produced by parietal cells (also called oxyntic cells) in the gastric glands in the stomach. Its secretion is a complex and relatively energetically expensive process. Parietal cells contain an extensive secretory network (called canaliculi) from which the hydrochloric acid is secreted into the lumen of the stomach. The pH of gastric acid is 1.5 to 3.5 in the human stomach lumen, the acidity being maintained by the proton pump H/K ATPase. The parietal cell releases bicarbonate into the bloodstream in the process, which causes a temporary rise of pH in the blood, known as an alkaline tide.
Bile acid
Prior to secreting any of the bile acids (primary or secondary, see below), liver cells conjugate them with one of two amino acids, glycine or taurine, to form a total of 8 possible conjugated bile acids. These conjugated bile acids are often referred to as bile salts because of their physiologically-important acid-base properties. The pKa of the unconjugated bile acids are between 5 and 6.5, and the pH of the duodenum ranges between 3 and 5, so when unconjugated bile acids are in the duodenum, they are almost always protonated (HA form), which makes them relatively insoluble in water. Conjugating bile acids with amino acids lowers the pKa of the bile-acid/amino-acid conjugate to between 1 and 4. Thus conjugated bile acids are almost always in their deprotonated (A-) form in the duodenum, which makes them much more water-soluble and much more able to fulfil their physiologic function of emulsifying fats.