While delving into the many features of Wolfram Mathematica v14.3, I was excited to see the new MoleculeFeatureDistance function. The nutrients and other chemicals that compose our foods lend themselves to pairs, such as vitamins D2 and D3 and omega-3 and omega-6 fatty acids.
With this function, also known as molecule fingerprint distance, Wolfram Mathematica v14.3 can compute the dissimilarity between two molecules. On a scale of 0 to 1, a smaller distance indicates higher similarity; a larger distance indicates greater dissimilarity. It’s a valuable new tool for everyone who studies food and nutrition.

Similar nutrient molecule pairs

Several nutrient pairs evaluated were very similar structurally, with short distances between their molecule features.

Polyunsaturated fatty acids: linoleic acid, alpha-linolenic acid

These two polyunsaturated fatty acids (PUFAs) are essential in our diet because they cannot be manufactured by our bodies. Both linoleic acid and alpha-linolenic acid molecules are 18-carbon chains and very similar in molecular structure, but that small variation in their structure makes them nutritionally distinct.
Found in plant-based oils, linoleic acid is an omega-6 fatty acid, with its first double bond located six carbons from the methyl end of the chain (–
CH
3
). Alpha-linolenic acid (ALA) is an omega-3 fatty acid, with its first double bond three carbons from the methyl end. Foods high in ALA include walnuts, flax seeds and certain plant-based oils. As an omega-3 fatty acid, ALA is beneficial for cardiovascular health.
In[]:=
MoleculeFeatureDistance
linoleic acid
CHEMICAL
,
linolenic acid
CHEMICAL

Out[]=
0.206897
In[]:=
MoleculePlot/@
linoleic acid
CHEMICAL
,
linolenic acid
CHEMICAL

Out[]=

,


Flavonoid antioxidants: quercetin, kaempferol

These flavonoid antioxidants, found in colorful fruits and vegetables, have a small molecule feature distance between them. Quercetin and kaempferol are classified as flavonols (a subgroup of flavonoids), giving foods color and flavor and helping prevent oxidation. The structural difference between the two molecules is the extra hydroxyl group (–OH) on quercetin’s B ring. In addition to fruits and vegetables like apples and broccoli, green tea and red wine are sources of these antioxidants.
In[]:=
MoleculeFeatureDistance
quercetin
CHEMICAL
,
kaempferol
CHEMICAL

Out[]=
0.216216
In[]:=
MoleculePlot/@
quercetin
CHEMICAL
,
kaempferol
CHEMICAL

Out[]=

,


Long-chain fatty acids: oleic acid, palmitic acid

These long-chain fatty acids are structurally similar. However, oleic acid is monounsaturated (one double bond), and palmitic acid is saturated (no double bonds), which affects their melting point and nutritional status. Oleic acid is abundant in olive oil and canola oil, while palmitic acid is found in animal fats and palm oil. Choose monounsaturated fats over saturated fats to reduce the risk of cardiovascular disease.
In[]:=
MoleculeFeatureDistance
oleic acid
CHEMICAL
,
palmitic acid
CHEMICAL

Out[]=
0.26087
In[]:=
MoleculePlot/@
oleic acid
CHEMICAL
,
palmitic acid
CHEMICAL

Out[]=

,


Vitamin D: ergocalciferol, cholecalciferol

There is greater understanding today of the importance of vitamin D to our health. Because vitamin D is involved in so many physiological processes, it often is considered a hormone, rather than a vitamin. The primary source of vitamin D2 (ergocalciferol) is plants, but few foods contain vitamin D2 naturally. Sun-dried mushrooms and mushrooms exposed to UV radiation before shipping can be sources of vitamin D2. Vitamin D3 (cholecalciferol) is found in fatty fish and fortified milk and breakfast cereals. Called the “sunshine vitamin,” synthesis of vitamin D in the skin during sun exposure is how much of the world gets its daily dose.
The vitamin D2 and vitamin D3 molecules differ in their side-chain structures. Vitamin D2 has an extra double bond and an additional methyl group. Both forms of vitamin D are well absorbed in the small intestine, but cholecalciferol is considered the more potent form.
In[]:=
MoleculeFeatureDistance
vitamin D2
CHEMICAL
,
vitamin D3
CHEMICAL

Out[]=
0.333333
In[]:=
MoleculePlot/@
vitamin D2
CHEMICAL
,
vitamin D3
CHEMICAL

Out[]=

,


Vitamin E: alpha-tocopherol, gamma-tocopherol

Vitamin E acts as an antioxidant to neutralize free radicals. Vitamin E tocopherols are found in nuts, seeds and related plant oils. Alpha-tocopherol is dominant in palm, olive and sunflower oils, while corn and soybean oils are higher in gamma-tocopherol. The tocopherols consist of a ring structure and a long saturated side chain. The number of methyl groups on the chromanol ring distinguishes alpha-tocopherol (3 methyl groups) from gamma-tocopherol (2 methyl groups).
In[]:=
MoleculeFeatureDistance
α-tocopherol
CHEMICAL
,
D-gamma-tocopherol
CHEMICAL

Out[]=
0.346154
In[]:=
MoleculePlot/@
α-tocopherol
CHEMICAL
,
D-gamma-tocopherol
CHEMICAL

Out[]=

,


Sterols: cholesterol, stigmasterol

Cholesterol is an important structural component of our cell membranes, making it vital to overall health. Our liver manufactures most of our cholesterol. Other cells synthesize cholesterol to a lesser extent, and animal-derived foods in our diet contribute the rest. Cholesterol is used to make vitamin D and hormones, including testosterone and estrogen. Too much cholesterol in the bloodstream, whether through diet or heredity, can lead to clogged arteries, so regular monitoring of serum lipid levels is recommended.
Stigmasterol is a phytosterol produced by almost all plants. The amounts vary by species. Bananas, cabbage, peanuts, soybeans, sunflowers, corn and seaweed are good sources of stigmasterol. Sterols have a multiple-ring structure that differs from other lipids. Like cholesterol, stigmasterol has a four-ring steroid nucleus. The major difference is in the side chain. Stigmasterol has an extra ethyl group (–
CH
2
CH
3
) and a double bond in the side chain, which makes its intestinal absorption rate low compared with cholesterol.
In[]:=
MoleculeFeatureDistance
cholesterol
CHEMICAL
,
stigmasterol
CHEMICAL

Out[]=
0.380952
In[]:=
MoleculePlot/@
cholesterol
CHEMICAL
,
stigmasterol
CHEMICAL

Out[]=

,


Methylxanthine alkaloids: caffeine, theobromine

Derived from the cacao plant, theobromine is found in chocolate. It has a bitter taste and, unlike caffeine, theobromine has little stimulant effect on the central nervous system. The reason lies in the structural difference of the molecules. Caffeine has three methyl groups, and theobromine has two. That third methyl group on the caffeine molecule means it can cross the blood-brain barrier and act on the central nervous system. For many of us, that’s a good thing, especially in the mornings.
In[]:=
MoleculeFeatureDistance
caffeine
CHEMICAL
,
theobromine
CHEMICAL

Out[]=
0.470588
In[]:=
MoleculePlot/@
caffeine
CHEMICAL
,
theobromine
CHEMICAL

Out[]=

,


Related, but at a distance

The molecular structure differences of these related nutrient pairs are greater than those we just examined.

Garlic: allicin, allyl methyl sulfide

When a fresh garlic clove is sliced, chopped or minced, the compound allicin is formed. Allicin is responsible for chopped garlic’s aroma and flavor. For an intense garlic taste in your dish, crush or finely mince the garlic to create the most allicin. Slice or roughly chop the garlic clove, which disrupts fewer cells, for a more subtle aroma and flavor. For just a hint of garlic in your dish, cook with whole cloves.
When we eat garlic, allicin breaks down to form sulfur-containing organic compounds, including allyl methyl sulfide. Of these compounds, allyl methyl sulfide takes the longest for the body to metabolize, which it then excretes through our skin and breath, causing “garlic breath.” As shown, allicin is a more complex molecule than allyl methyl sulfide.
In[]:=
MoleculeFeatureDistance
allicin
CHEMICAL
,
allyl methyl sulfide
CHEMICAL

Out[]=
0.666667
In[]:=
MoleculePlot/@
allicin
CHEMICAL
,
allyl methyl sulfide
CHEMICAL

Out[]=

,


Carotenoids: beta-carotene, lycopene

Carotenoid pigments are found in colorful fruits and vegetables. Beta-carotene is the most abundant carotenoid in most diets. It’s a precursor of vitamin A and is converted to vitamin A in the intestine and liver. First recognized in 1881, vitamin A is important for vision, normal growth, reproduction and immunity. Carrots, sweet potatoes and mangoes are good sources of beta-carotene. Lycopene is abundant in tomatoes and tomato-based products, giving them their vibrant color. Lycopene is a powerful antioxidant that may reduce the risk of certain cancers, including prostate cancer.
The beta-carotene molecule has rings at both ends, while the lycopene molecule is acyclic (no rings). Due to the molecule’s lack of a cyclic configuration, lycopene cannot make vitamin A. However, like beta-carotene, lycopene has double bonds along the length of the molecule, which are responsible for the vivid pigments produced by these carotenoids.
In[]:=
MoleculeFeatureDistance
beta-carotene
CHEMICAL
,
lycopene
CHEMICAL

Out[]=
0.711111
In[]:=
MoleculePlot/@
beta-carotene
CHEMICAL
,
lycopene
CHEMICAL

Out[]=

,


Distinctly different

It’s easy to see the differences in structure between molecules that are closer to 1.0 in their MoleculeFeatureDistance value.

Visualizations

Compare multiple distance values with BarChart:
Visualize the distances among all 20 amino acids with ClusteringTree:
Verify the tree structure by checking the amino acids with the shortest distances to L-serine:

CITE THIS NOTEBOOK

Molecular structure comparisons of nutrients and food chemicals​
by Gay Wilson​
Wolfram Community, STAFF PICKS, August 18, 2025
​https://community.wolfram.com/groups/-/m/t/3532416