text:
## Coupling Through Emergent Conservation Laws (Part 8)

#### John Baez, Jonathan Lorand, Blake Pollard, and Maru Sarazola

To wrap up this series, let's look at an even more elaborate cycle of reactions featuring emergent conservation laws: the citric acid cycle. Here's a picture of it from Stryer's textbook Biochemistry:

I'll warn you right now that we won't draw any grand conclusions from this example: that's why we left it out of our paper. Instead we'll leave you with some questions we don't know how to answer.

All known aerobic organisms use the citric cycle to convert energy derived from food into other useful forms. This cycle couples an exergonic reaction, the conversion of acetyl-CoA to CoA-SH, to endergonic reactions that produce ATP and a chemical called NADH.

The citric acid cycle can be described at various levels of detail, but at one level it consists of ten reactions:

$$\begin{array}{rcl} \mathrm{A}_1 + \text{acetyl-CoA} + \mathrm{H}_2\mathrm{O} & \longleftrightarrow & \mathrm{A}_2 + \text{CoA-SH} \\ \\ \mathrm{A}_2 & \longleftrightarrow & \mathrm{A}_3 + \mathrm{H}_2\mathrm{O} \\ \\ \mathrm{A}_3 + \mathrm{H}_2\mathrm{O} & \longleftrightarrow & \mathrm{A}_4 \\ \\ \mathrm{A}_4 + \mathrm{NAD}^+ & \longleftrightarrow & \mathrm{A}_5 + \mathrm{NADH} + \mathrm{H}^+ \\ \\ \mathrm{A}_5 + \mathrm{H}^+ & \longleftrightarrow & \mathrm{A}_6 + \textrm{CO}_2 \\ \\ \mathrm{A}_6 + \mathrm{NAD}^+ + \text{CoA-SH} & \longleftrightarrow & \mathrm{A}_7 + \mathrm{NADH} + \mathrm{H}^+ + \textrm{CO}_2 \\ \\ \mathrm{A}_7 + \mathrm{ADP} + \mathrm{P}_{\mathrm{i}} & \longleftrightarrow & \mathrm{A}_8 + \text{CoA-SH} + \mathrm{ATP} \\ \\ \mathrm{A}_8 + \mathrm{FAD} & \longleftrightarrow & \mathrm{A}_9 + \mathrm{FADH}_2 \\ \\ \mathrm{A}_9 + \mathrm{H}_2\mathrm{O} & \longleftrightarrow & \mathrm{A}_{10} \\ \\ \mathrm{A}_{10} + \mathrm{NAD}^+ & \longleftrightarrow & \mathrm{A}_1 + \mathrm{NADH} + \mathrm{H}^+ \end{array}$$

Here $$\mathrm{A}_1, \dots, \mathrm{A}_{10}$$ are abbreviations for species that cycle around, each being transformed into the next. It doesn't really matter for what we'll be doing, but in case you're curious:

• $$\mathrm{A}_1=$$ oxaloacetate,
• $$\mathrm{A}_2=$$ citrate,
• $$\mathrm{A}_3=$$ cis-aconitate,
• $$\mathrm{A}_4=$$ isocitrate,
• $$\mathrm{A}_5=$$ oxalosuccinate,
• $$\mathrm{A}_6=$$ α-ketoglutarate,
• $$\mathrm{A}_7=$$ succinyl-CoA,
• $$\mathrm{A}_8=$$ succinate,
• $$\mathrm{A}_9=$$ fumarate,
• $$\mathrm{A}_{10}=$$ L-malate.

In reality, the citric acid cycle also involves inflows of reactants such as acetyl-CoA, which is produced by metabolism, as well as outflows of both useful products such as ADP and NADH and waste products such as CO2. Thus, a full analysis requires treating this cycle as an open chemical reaction network, where species flow in and out. However, we can gain some insight just by studying the emergent conservation laws present in this network, ignoring inflows and outflows — so let's do that!

There are a total of 22 species in the citric acid cycle. There are 10 forward reactions. We can see that their vectors are all linearly independent as follows. Since each reaction turns $$\mathrm{A}_i$$ into $$\mathrm{A}_{i+1}$$, where we count modulo 10, it is easy to see that any nine of the reaction vectors are linearly independent. Whichever one we choose to `close the cycle' could in theory be linearly dependent on the rest. However, it is easy to see that the vector for this reaction

$$\mathrm{A}_8 + \mathrm{FAD} \longleftrightarrow \mathrm{A}_9 + \mathrm{FADH}_2$$

is linearly independent from the rest, because only this one involves FAD. So, all 10 reaction vectors are linearly independent, and the stoichiometric subspace has dimension 10.

Since 22 - 10 = 12, there must be 12 linearly independent conserved quantities. Some of these conservation laws are 'fundamental', at least by the standards of chemistry. All the species involved are made of 6 different atoms (carbon, hydrogen, oxygen, nitrogen, phosphorus and sulfur), and conservation of charge provides another fundamental conserved quantity, for a total of 7.

(In our example from last time we didn't keep track of conservation of hydrogen and charge, because both $$\mathrm{H}^+$$ and $$e^-$$ ions are freely available in water... but we studied the citric acid cycle when we were younger, more energetic and less wise, so we kept careful track of hydrogen and charge, and made sure that all the reactions conserved these. So, we'll have 7 fundamental conserved quantities.)

For example, the conserved quantity

$$[\text{acetyl-CoA}] + [\text{CoA-SH}] + [\mathrm{A}_7]$$

arises from the fact that $$\text{acetyl-CoA}$$, $$\text{CoA-SH}$$ and $$\mathrm{A}_7$$ contain a single sulfur atom, while none of the other species involved contain sulfur.

Similarly, the conserved quantity

$$3[\mathrm{ATP}] + 2[\mathrm{ADP}] + [\mathrm{P}_{\mathrm{i}}] + 2[\mathrm{FAD}] +2[\mathrm{FADH}_2]$$

expresses conservation of phosphorus.

Besides the 7 fundamental conserved quantities, there must also be 5 linearly independent emergent conserved quantities: that is, quantities that are not conserved in every possible chemical reaction, but remain constant in every reaction in the citric acid cycle. We can use these 5 quantities:

• $$[\mathrm{ATP}] + [\mathrm{ADP}]$$, due to the conservation of adenosine.

• $$[\mathrm{FAD}] + [\mathrm{FADH}_2]$$, due to conservation of flavin adenine dinucleotide.

• $$[\mathrm{NAD}^+] + [\mathrm{NADH}]$$, due to conservation of nicotinamide adenine dinucleotide.

• $$[\mathrm{A}_1] + \cdots + [\mathrm{A}_{10}]$$. This expresses the fact that in the citric acid cycle each species $$[\mathrm{A}_i]$$ is transformed to the next, modulo 10.

• $$[\text{acetyl-CoA}] + [\mathrm{A}_1] + \cdots + [\mathrm{A}_7] + [\text{CoA-SH}]$$. It can be checked by hand that each reaction in the citric acid cycle conserves this quantity. This expresses the fact that during the first 7 reactions of the citric acid cycle, one molecule of $$\text{acetyl-CoA}$$ is destroyed and one molecule of $$\text{CoA-SH}$$ is formed.

• Of course, other conserved quantities can be formed as linear combinations of fundamental and emergent conserved quantities, often in nonobvious ways. An example is

$$3 [\text{acetyl-CoA}] + 3 [\mathrm{A}_2] + 3[\mathrm{A}_3] + 3[\mathrm{A}_4] + 2[\mathrm{A}_5] +$$ $$2[\mathrm{A}_6] + [\mathrm{A}_7] + [\mathrm{A}_8] + [\mathrm{A}_9] + [\mathrm{A}_{10}] + [\mathrm{NADH}]$$

which expresses the fact that in each turn of the citric acid cycle, one molecule of $$\text{acetyl-CoA}$$ is destroyed and three of $$\mathrm{NADH}$$ are formed. It is easier to check by hand that this quantity is conserved than to express it as an explicit linear combination of the 12 conserved quantities we have listed so far.

Finally, we bit you a fond farewell and leave you with this question: what exactly do the 7 emergent conservation laws do? In our previous two examples (ATP hydrolysis and the urea cycle) there were certain undesired reactions involving just the species we listed which were forbidden by the emergent conservation laws. In this case I don't see any of those. But there are other important processes, involving additional species, that are forbidden. For example, if you let acetyl-CoA sit in water it will 'hydrolyze' as follows:

$$\text{acetyl-CoA} + \mathrm{H}_2\mathrm{O} \longleftrightarrow \text{CoA-SH} + \text{acetate} + \text{H}^+$$

So, it's turning into CoA-SH and some other stuff, somewhat as does in the citric acid cycle, but in a way that doesn't do anything 'useful': no ATP or NADH is created in this process. This is one of the things the citric acid cycle tries to prevent.

(Remember, a reaction being 'forbidden by emergent conservation laws' doesn't mean it's absolutely forbidden. It just means that it happens much more slowly than the catalyzed reactions we are listing in our reaction network.)

Unfortunately acetate and $$\text{H}^+$$ aren't on the list of species we're considering. We could add them. If we added them, and perhaps other species, could we get a setup where every emergent conservation law could be seen as preventing a specific unwanted reaction that's chemically allowed?

Ideally the dimension of the space of emergent conservation laws would match the dimension of the space spanned by reaction vectors of unwanted reactions, so 'everything would be accounted for'. But even in the simpler example of the urea cycle, we didn't achieve this perfect match.


text:
# Will the non-colluding servers communicate in IT-PIR schemes ?

The current literature around Information Theoretic Private Information Retrieval (IT-PIR) schemes assume the existence of multiple copies of the database distributed across non-colluding servers. Much of the research seems to be around the servers not communicating with each other but only with the client.

Can the results be improved (or are there known results) ? when the the multiple servers communicate among themselves without breaking the security assumptions (say using multiparty computation) ?

format: plain


text:
Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

# Chocolate-based Ink Three-dimensional Printing (Ci3DP)

## Abstract

Recent advances in three-dimensional (3D) printing technology has enabled to shape food in unique and complex 3D shapes. To showcase the capability of 3D food printing, chocolates have been commonly used as printing inks, and 3D printing based on hot-melt extrusion have been demonstrated to model 3D chocolate products. Although hot-melt extrusion of chocolates is simple, the printing requires precise control over the operating temperature in a narrow range. In this work, for the first time, we directly printed chocolate-based inks in its liquid phase using direct ink writing (DIW) 3D printer to model complex 3D shapes without temperature control. We termed this method as chocolate-based ink 3D printing (Ci3DP). The printing inks were prepared by mixing readily available chocolate syrup and paste with cocoa powders at 5 to 25 w/w% to achieve desired rheological properties. High concentrations of cocoa powders in the chocolate-based inks exhibited shear-thinning properties with viscosities ranging from 102 to 104 Pa.s; the inks also possessed finite yield stresses at rest. Rheology of the inks was analyzed by quantifying the degree of shear-thinning by fitting the experimental data of shear stress as a function of shear rate to Herschel-Bulkley model. We demonstrated fabrication of 3D models consisting of chocolate syrups and pastes mixed with the concentration of cocoa powders at 10 to 25 w/w%. The same method was extended to fabricate chocolate-based models consisting of multiple type of chocolate-based inks (e.g. semi-solid enclosure and liquid filling). The simplicity and flexibility of Ci3DP offer great potentials in fabricating complex chocolate-based products without temperature control.

## Introduction

This paper describes an approach to perform 3D printing of chocolate-based materials in its liquid phase at room temperature, termed chocolate-based ink 3D printing (Ci3DP). We printed the chocolate-based inks in the form of chocolate syrup and chocolate paste mixed with varying concentrations of cocoa powders. The rheology-modified chocolate-based inks exhibited viscous and Herschel-Bulkley fluid properties, and they were printable using a DIW 3D printer without temperature control. Ci3DP is complementary to currently available methods of 3D printing of chocolates based on hot-melt extrusion where the printing ink is heated and molten before patterning. Wide selection of chocolate-based materials, and ability to tailor their properties, distinguish our current approach as a unique method to 3D print chocolate-based products at room temperature.

Recent advance in digital fabrication, in particular 3D printing, has enabled free-form fabrication of 3D structures and devices from plastics, metals, and other raw materials. To date, 3D printed structures have demonstrated a wide range of applications including sensing1,2, tissue engineering3,4 and physiological vascular modelling5,6. Recent frontier of 3D printing has focused direct printing of edible materials7,8,9. 3D food printing allows printing of foods with customized contents of nutrients, where the nutrients can be, in principle, optimized based on biometric and genomic information10. Similarly, to other 3D printing techniques, 3D food printing relies on layer-by-layer fabrication based on the CAD data and sequential depositions of 2D layers. The food inks can be customized by concerted combination of the essential ingredients of food such as carbohydrates, proteins and fat. Different 3D printing techniques, selective laser sintering (SLS), ink-jet printing, hot-melt extrusion and binder jetting, have been demonstrated for 3D food printing11. Amongst all, extrusion is the most popular method in 3D food printing. During extrusion, materials (which are liquid, semi-solid or solid) are forced through a nozzle to fabricate 3D objects. There are three types of extrusion techniques: cold, hot-melt and gel-forming extrusion12. Cold extrusion is performed at room temperature without phase change. Hot-melt extrusion is primarily based on the mechanism similar to fused deposition modeling (FDM)13: (1) heating to flow the ink out of the nozzle and (2) cooling to solidify molten chocolates in the bed. Gel-formation extrusion involves phase change after extrusion of liquid materials. Techniques based on extrusion have limitations with respect to the stability and self-supporting properties of the printed objects11. Nevertheless, owing to their simplicity, extrusion has been used to print different types of foods14.

Chocolate, a complex emulsion of fine solid particles of sugar and cocoa in a continuous fat phase15, is a universally loved food. As a material, chocolates are solid at room temperature (20 to 25 °C), and melt in human mouth and saliva (37 °C)16. The melting characteristics and the texture of chocolates depends on the types and proportions of cocoa and other ingredients, and the methods to blend and process them17. The components are mixed, refined and conched during processing so that a suitable viscosity of chocolate is obtained prior to tempering17. Chocolates are commonly used for the demonstration of 3D food printing because it can be patterned by hot-melt extrusion and it becomes solid at room temperature. Several studies related to hot-melt extrusion of chocolate are available in the literature13,18,19,20,21. In the reported experiments, the chocolate was melted and dispensed at the temperature of 31 to 36 °C; the attention to temperature was required because the rheological characteristics of the molten chocolate was sensitive to temperature. Hot-melt extrusion of chocolate offers advantages in simplicity and accessibility, while there is a drawback inherent to its printing mechanism; the control over the narrow range of operating temperature is required. Cold extrusion depends solely on the rheology of printing ink at the operating temperature11. The manipulation of temperature is not required, and the entire printing can be performed at room temperature. 3D modelling of chocolate-based materials by cold extrusion has not been well-studied to date, however, due to the lack of inks possessing suitable rheological properties.

To bridge this gap, we developed a method to print chocolate-based inks at room temperature by cold extrusion. In this study, ‘chocolate-based inks’ are defined as liquid chocolate products mixed with cocoa powders; readily available chocolate products (i.e. syrups and pastes) were mixed with cocoa powder to alter the rheology of the ink. The rheological properties of the chocolate-based inks were studied to identify the properties suitable for DIW at the room temperature. To obtain good print fidelity, the effects of the three parameters of the printing—applied pressure (P), deposited mass of the ink per unit length (m) and the distance between two layers (Δz)—were studied. Under the conditions optimized for printing, we demonstrated to create 3D models using a single and multiple chocolate-based inks. Ci3DP is capable of fabricating 3D structures at room temperature, and the principles and methods presented here should expand the toolkit of 3D food printing and should be applicable to 3D print other edible inks by a DIW printer.

## Results

### Overview of the study

The general scheme of Ci3DP is shown in Fig. 1(a). Chocolate-based inks were formulated by mixing syrup and paste with cocoa powder (Fig. 1(b)). We evaluated the printability of the chocolate-based inks in two terms: (1) rheological properties of the chocolate-based inks and (2) parameters of DIW 3D printing. The rheological properties of the formulated inks determined the suitability of the inks to perform cold extrusion. The formulated inks must exhibit shear-thinning behavior for easy extrusion through the syringes and nozzles, and form self-supporting layers after extrusion to maintain the printed structures (Fig. 1(c) and Supplementary Information). We confirmed that the dimension of the printed inks were maintained without spreading when the ink contained high concentration of cocoa powders. Commercially available cake icing was used without modification as a reference of a printable material with suitable rheological properties. Thereafter, the parameters of 3D printing were identified (Fig. 1(d)). A DIW 3D printer consisted of a dispenser and a motion control robot (Fig. S1). We identified the operating parameters for the successful 3D modelling of chocolate-based inks to ensure proper attachment between printed layers, and demonstrated fabrication of 3D models consisting of chocolate-based inks without temperature control.

### Parameters in Ci3DP

Successful Ci3DP required the chocolate-based ink with adequate rheological properties, and the use of the right setting of the instrument. In brief, DIW 3D printing have three different elements requiring optimization: ink, dispenser, and robot (Supplementary Fig. S1). Firstly, the printing ink must exhibit suitable rheological characteristics. We discuss in the next section that yield stress (σy) and the storage modulus (G′) of the ink were the most crucial parameters that governed the outcomes of printing. Secondly, the dispenser (consisting of the pressure source, syringe and nozzle) determined the rate of mass flow dispensed from the nozzle. The nozzle attached to the syringe provided high fluidic resistance to the viscous fluid flowing through it. The applied pressure drop (ΔP) and the diameter of the nozzle (d) governed the rate of mass flow through the given nozzle ($$\dot{m}$$). Finally, the motion-control robot (attached to the syringe and the nozzle) controlled the movement of the syringe during the deposition of the ink. The velocity of the dispensing head (i.e. syringe and nozzle) (v) determined the mass of the ink dispensed per unit length (m = $$\dot{m}/v$$). The robot also offered the control over the motion in the vertical direction (i.e. perpendicular to the layer of printing). When the 3D model is created layer by layer, the distance between adjacent layers (Δz) and the nozzle-to-substrate distance (h) were considered to achieve good print fidelity (Supplementary information). We summarized the relationship between the investigated parameters (Fig. 1(d)).

### Rheological characterization of chocolate-based inks

Initially, we characterized the chocolate-based inks for viscosity (μ), yield stress (σy) and recovery behavior. The inks were prepared by adding cocoa powders to chocolate syrup (10 to 25 w/w%; 10 w/w % is denoted as S10 etc) and to chocolate paste (5 to 12 w/w%, 5 w/w% is denoted as P5 etc). The measurements of μ as a function of shear rate ($$\dot{\gamma }$$) are presented (Supplementary Fig. S2). For the range of the concentrations we explored, the addition of cocoa powder increased μ by 104 for chocolate syrups (101 Pa.s for S0 and 104 Pa.s for S25) and by 102 for chocolate pastes (~800 Pa.s for P0 and 104 Pa.s for P12). Previous studies have shown that the inks with μ > 100 Pa.s were printable by a DIW 3D printer22,23. The viscosity of the inks decreased as $$\dot{\gamma }$$ increased, suggesting the shear-thinning behavior. This property was desirable for DIW because the ink needs to be dispensed through narrow nozzles at the pressure provided by the dispenser.

An important insight into printability is provided by σy of the inks. To determine σy of the inks, a shear stress ramp was performed; σy was analyzed by observing μ at which the ink started flowing. As shear stress (σ) was gradually increased, sudden decrease in μ suggested yielding of the fluid (Fig. 2(a) for chocolate syrup and Supplementary Fig. S3(a) for chocolate paste). σy was determined using the intersection point of two tangents—one in the plateau-region of μ where the ink deformed elastically and one in the region where μ dropped and the ink started to flow (Supplementary Fig. S3(b)). The van der Waals interactions between the colloidal particles were broken once σ exceeded σy. The values of σy was measured as a function of the concentration of cocoa (Fig. 2(b)). The measurement suggested that the addition of the cocoa powder increased σy from 0 (S0) to 277 ± 22 Pa (S25) for the chocolate syrup, and from 54 ± 8 (P0) to 298 ± 16 Pa (P12) for the chocolate paste. The increase in σy suggested that the colloidal network within the ink was reinforced by high cocoa concentration. As a reference material, σy for unmodified cake icing was measured to be 220 ± 8 Pa. The cake icing forms self-supporting layers (as they are used to create 3D decorations on cakes), and our measurement verified that formulated chocolate-based inks possessed the same order of σy as cake icing. The high values of σy guaranteed the inks to maintain the printed structures once printed.

### Shear-thinning behaviors of the ink

It is desirable that the printing ink possess shear-thinning properties to dispense the inks at low pressure in DIW 3D printing. We confirmed that the formulated chocolate-based inks exhibited shear-thinning flow behaviors. The behaviors of the ink was approximated by the Herschel-Bulkley (HB) model24:

$$\sigma ={\sigma }_{y}+K{\dot{\gamma }}^{n}$$
(1)
$${\log }_{10}(\sigma -{\sigma }_{y})={\log }_{10}K+n\,{\log }_{10}\dot{\gamma }$$
(2)

where K is the flow consistency index (a measure of the viscosity of the fluid in Pa.sn), and n is the shear-thinning index (n = 1 for Newtonian fluids, n < 1 for shear-thinning fluids and n > 1 for shear-thickening fluids). The values of K and n were determined by plotting (σσy) with respect to $$\dot{\gamma }$$ on the logarithmic axes and fitting a straight line in the form of Eq. (2) (Supplementary Fig. S4)25. The HB model provided a fit with R2 > 0.95 for all inks we tested in the experiment. The calculated values of K and n are shown (Fig. 2(c)). For the cake icing, the value of n was 0.4, confirming the shear-thinning property. With addition of cocoa powder in syrup, n decreased from 0.7 (S15) to 0.3 (S25) as the cocoa concentration was increased (Fig. 2(c), solid circles). For the inks based on the chocolate paste, slight increase in n from 0.5 (P0) to 0.6 (P12) was observed as the cocoa concentration was increased. The lower n suggested the higher degree of shear-thinning of the ink. The value of K increased as the cocoa concentration increased for both syrup and paste. Overall, the high values of K for the chocolate-based inks suggested improved mechanical strength to retain shapes after being dispensed from the nozzle26.

The oscillatory amplitude sweep tests were performed to study the viscoelastic properties of the printing inks (Fig. 2(d) and Supplementary Fig. S5(a)). Oscillatory amplitude sweep tests provided details of the microstructure of the inks. The response of storage modulus (G′, a measure of elastic response of the ink) and loss modulus (G′′, a measure of viscous response of the ink) with applied sinusoidal oscillatory shear was observed. Further, oscillatory stress sweeps were used to analyze the yield behavior of the inks. At low shear stress, G′ for all the inks remained constant, and a linear viscoelastic region (LVR) was observed (except for S0 and S10 which showed liquid-like behaviors, which were not suitable to fabricate 3D models). In this region, the internal structure of the inks remained unchanged or undamaged due to their elastic behavior. The solid-like behavior of the inks in LVR was confirmed for the condition of G′ > G′′. G′ in LVR gradually increased with increasing concentration of cocoa powder in the inks, suggesting the presence of strong interactions between the colloidal particles (Supplementary Fig. S5(b)). For the inks formulated with the syrup, G′ increased by five orders from S0 to S25. For the inks formulated with paste, the general behaviors were the same as those with the syrup; G′ ranged from 104 Pa (P0) to 106 Pa (P12). The broad LVR of the inks with high concentrations of cocoa powders (S20, S25, P10 and P12) indicated high resistance to the applied stresses to maintain the structures (Supplementary Fig. S5(b)). These inks withstood applied oscillatory stress of 101 to 102 Pa before the structure breakdown occurred.

The gradual decrease in G′ indicated collapse of the ink structure and subsequent breakdown resulting in liquid-like behaviors. To gain insights into the liquid-like and solid-like behaviors of the inks, we estimated yield stress by two ways: (1) deviation of G′ from LVR, measuring the yield point (σ1) that indicated the onset of fall in the value of G′, and (2) crossover of G′ and G′′, measuring the yield point (σ2) that indicated the transition from solid-like to liquid-like behaviors27 (Supplementary Fig. S5(c)). σ1 was determined from the intersection of two lines: one fitted to the values in the LVR and another fitted to G′ beyond the LVR28. As expected, cake icing exhibited large values of σ1 = 132 ± 10 Pa and σ2 = 353 ± 25 Pa. Based on the measured values of σ1 and σ2, the unmodified syrup (S0) was more liquid-like than the unmodified paste (P0) (Supplementary Fig. S5(c)). The values of σ1 and σ2 increased with increasing concentration of cocoa (Supplementary Fig. S5(c)). The difference in the values of σ1 and σ2 was less for the inks based on the paste than those based on the syrup, suggesting fast solid-liquid transition. Both G′ and G′′ of the rheology-modified syrups and pastes exhibited overshoots and following decreases at intermediate strain amplitude (Supplementary Fig. S5(d)). This observation suggested Type IV (strong strain overshoot) large amplitude oscillatory shear (LAOS) behavior, a characteristic of strong intermolecular interactions of the network microstructure29. For cake icing, only G′′ showed an overshoot at intermediate strain amplitude followed by decreasing values suggesting Type III (weak strain overshoot) LAOS behavior29 (Supplementary Fig. S5(d)). Such behaviors may be attributed to a transition from an ordered structure to a disordered structure (i.e. breakdown of the microstructures) that occurs during shearing of the suspensions29,30,31. Further investigation will be needed to understand the physical mechanism of the complex behavior of strain overshoot observed for the studied inks.

Finally, we performed thixotropic loop tests to study the time-dependent breakdown and recovery of the microstructure of the printing inks. The results of the experiments are summarized (Supplementary Fig. S6 and Supplementary Information). We confirmed that degree of thixotropy increased by the addition of the cocoa powder. The thixotropic loop area increased from S0 (19 ± 3 Pa/s) to S25 (5186 ± 462 Pa/s) for the syrup, and P0 (435 ± 47 Pa/s) to P25 (5531 ± 562 Pa/s) for the paste, respectively (Supplementary Fig. S6(b)). Similarly, thixotropic loop area of cake icing was measured to be 889 ± 65 Pa/s. These measurements suggested that the syrup and the paste acquired characteristics of a thixotropic fluid by the addition of cocoa powders.

Overall, we studied the rheological properties of the chocolate-based inks by the addition of the cocoa powders. The ideal ink for DIW 3D printing should be shear-thinning for the ease of dispensing, and should possess high σy and G′ to retain the resolution of the printed structures without spreading. Overall, previous studies suggested the values of σy and G′ for successful DIW 3D printing; inks with σy ~ 102 to 103 Pa and G′ ~ 103 to 104 Pa resulted in good fidelity of printing32,33,34. The fidelity of printing was not confirmed by previously reported rheological characterization of the printing inks. For example, in the study by Lille34, it was reported that the ink with σy = 60 Pa and G′ = 500 Pa was able to retain the printed shape after extrusion. Two cases were reported for the failure of printing; the ink with σy = 100 Pa and G′ = 36000 Pa experienced the difficulty of extrusion though the nozzle, and the ink with σy = 8 Pa and G′ of 300 Pa could not retain the printed shape34. By comparing the values of σy and G′ of the chocolate-based inks to that of reported values, S20, S25, P10 and P12 appeared to be suitable inks for Ci3DP. We also note that the formulated chocolate-based ink possessed similar rheological properties to cake icing, a material known to form self-supporting 3D structures.

### Flow of an ink through a nozzle

The chocolate-based ink was extruded through the nozzle under an applied pressure (ΔP = PPatm) in Ci3DP. The extrusion of the inks through the nozzles influence the process-related rheological properties; the process-related μ is lower than μ measured by rheometry35. It was therefore important to estimate the ink properties from the measurements relevant to the actual process. First, we quantified the relationship between the rate of volumetric flow of the inks (Q) and ΔP for S0 to S25, P0 to P12 and cake icing with the nozzles of d = 410 to 840 μm (22 to 18 Gauges) for ΔP = 100 to 550 kPa. The measurements confirmed that, for the given ink, Q increased nonlinearly with increasing ΔP and with increasing d (Supplementary Fig. S7). The high concentration of the cocoa powder resulted in high μ and hence low Q. The trends observed in the plots of Q as a function of ΔP allowed to estimate the required pressure to achieve adequate flow rate to model 3D structures by Ci3DP. We used two dimensionless groups to characterize the flow of the inks through the nozzle: the Reynolds number (Re),

$$Re=\frac{\rho {v}_{i}d}{\mu }$$
(3)

and the dimensionless pressure drop (ΔP*),

$$\Delta {P}^{\ast }=\frac{\Delta P}{\rho {v}_{i}^{2}/2}$$
(4)

where d, ρ and vi are the diameter of the nozzle, the density of the ink and the average velocity of the ink through the nozzle, respectively. The plot of ΔP* against Re for all the inks exhibited similar linear trends with some scatter (Fig. 3). ΔP* decreased inversely with Re; this observation suggested the characteristic viscous-dominated flow36, where viscous effects dominate over inertial effects of chocolate-based inks at small Re (Re < 1).

### Influence of types of nozzles on Q of inks

We used two types of nozzles in Ci3DP, a general-purpose nozzle and a tapered nozzle (Supplementary Fig. S8(a)). The resistance of a tapered nozzle was lower than that of a general-purpose nozzle with the same diameter of the outlet; a general-purpose nozzle has a choke point that would prevent or lower the flow of viscous inks. We compared the nozzles with d = 600 μm (at the exit area); we dispensed P10 for ΔP = 100 to 550 kPa and measured Q (Supplementary Fig. S8(b)). For a given ΔP, Q of the ink in a tapered nozzle was larger by 2 to 3 times that the values of Q in a general-purpose nozzle with the same inner diameter of the outlet. For a general-purpose nozzle, more than 90% of the total pressure drop occurs in the last 40% of the length of the nozzle36. In contrast, for a tapered nozzle, more than 90% of the total pressure drop occurs in less than the last 20% of the length of the nozzle36. The use of tapered nozzle ensured a smooth flow of the ink, and lowered the required pressure applied by the dispenser for the high viscous inks such as S25 and P12. While ΔP is the printing parameter most convenient to vary to adjust Q, the change in the nozzle type (i.e. a general-purpose nozzle or a tapered nozzle) also allowed to vary Q for the fixed value of ΔP. In practice, the use of tapered nozzles was preferred because the printing was performed at low pressure.

The printed structure may be affected due to spreading of the inks at time tp, where tp is the time after printing. Spreading of the ink is pronounced for the inks with low yield stress (σy). We highlighted this problem by printing a 3D mesh (4 cm × 4 cm) with four layers of chocolate-based inks based on the syrups (S0 to S25) (Fig. 4(a)) and those based on the pastes (P0 to P12) (Fig. 4(b)). We observed that the printed S0, S10 and S15 started spreading immediately while printing (Supplementary Movie S1). σy (2 to 23 Pa for S0 to S15) and G′ (113 ± 7 Pa for S15) of the ink were not sufficiently high, and the printed structure yielded to the gravity (the magnified images in Supplementary Fig. S9). In contrast, S20 (σy = 142 ± 5 Pa, and G′ = 1670 ± 115 Pa) and S25 (σy = 277 ± 22 Pa, and G′ = 35000 ± 3000 Pa) retained the shape of the printed inks for 30 min (Supplementary Movie S2). The large values of σy and G′ for S20 and S25 allowed the inks to form self-supporting layers. Similarly, we fabricated 3D meshes consisting of four layers of the inks formulated with the chocolate pastes (P0 to P12) (Fig. 4(b)). The values of σy were slightly higher than those for the inks formulated with syrups. The spreading of the printed inks was observed for P0; the width of the printed ink increased over 30 min. The width of the filament remained nearly constant for P5, P7.5, P10 and P12. Interestingly, the adjacent layers vertically fused at the locations in contact for the models fabricated in P5 and P7.5, while the different layers of the models consisting of P10 and P12 remained disjoint for 30 min after printing (Supplementary Fig. S9). These experiments highlighted the importance of non-Newtonian rheology of the printing inks on the fidelity of printing. Spreading of the printed structures were avoided by adding large amount of the cocoa powders to the syrup (20 to 25 w/w%) and to the paste (10 to 12 w/w%). The rheology of printing also affected the vertical attachment of different layers, which needs to be ensured to have 3D models.

### Shear-thinning inks and print fidelity

The attainable 3D models also depended on shear-thinning property of the inks. We discussed earlier that the chocolate-based inks and cake icing were yield stress and shear-thinning fluids. For such fluids, there are some time lags before the terminal volumetric flow rate (Q) was achieved after a given pressure was applied. These time lags need to be compensated to attain proper 3D models. In this section, we used cake icing as a model ink to understand the behavior of the printed inks; the same observations should be applicable for other types of chocolate-based inks. The paths to dispense two layers of the mesh are shown (Supplementary Fig. S10). We observed the gaps in the printed models at the points where dispensing was started (i.e. the top left corner of the mesh) (Fig. 5(a)). The attachment of filaments at the corner was compromised and the gaps were formed (Fig. 5(a), inset). These gaps formed due to the time lag associated with the dispensing of viscous shear-thinning solution (μ = 2 × 104 Pa.s for cake icing). The ink did not attain the terminal volumetric flow rate (Q) immediately after applying the constant pressure for dispensing, resulting in incomplete sealing at the corners of the model. To compensate for this time lag, we stopped the motion of the nozzle for some time (τ) at every point where the dispensing started (e.g. τ = 0.2 s used for cake icing). Intended 3D models were obtained with the compensation of time (Fig. 5(b)). Generally, inks with large values of μ required to account for the time lag; S20, S25, P10 and P12 (μ ~ 103 to 104 Pa.s) required τ = 0.2 to 0.5 s to achieve the best print fidelity. In contrast, S0, S10 and S15 did not require such compensation, and τ = 0 was used for printing (although the printed models failed due to spreading of the inks). This consideration allowed fabricating relatively complex structures of cake icing at room temperature by DIW; a 3D object representing a knight was fabricated using cake icing with proper attachment of the printed inks (Fig. 5(c)).

### 3D structures by Ci3DP

With appropriate printing inks and operating parameters, we demonstrated fabrication of 3D models consisting of chocolate-based materials. The fabricated 3D structures of S20 and S25 are showcased (Fig. 6). These demonstrations highlighted the advantages of addition of cocoa powder to the inks in terms of (1) viscosity of the printing ink (ranging from 102 to 104 Pa.s) and (2) alteration of ink behavior from liquid-like to solid-like with yield stress. Unlike the hot-melt extrusion of chocolate 3D printing, all demonstrations in the current work was done at the room temperature without any heating elements. A Bulbasaur with a big cavity at the back was printed (front, side and top views in Fig. 6(a)). Different 3D geometries were directly fabricated (Fig. 6(b) to (f)) on the glass substrate. Using appropriate calibrations performed in the z-direction, we also performed Ci3DP on another edible substrate (e.g. a biscuit) (Fig. 6(g)). In the same way, 3D models consisting of P7.5 to P12 were printed (Supplementary Fig. S11). Overall, cocoa powders was used as an additive to modify the rheological properties of chocolate syrups and pastes. Characterization of their rheological properties ensured that the inks were appropriate to form self-supporting layers to form 3D structures. We foresee other materials with long polymer chains (such as starch and other carbohydrate derivatives) would serve as an effective additive for the formation of printable inks.

### Multi-material Ci3DP

Finally, we demonstrated multi-material printing for Ci3DP using a DIW 3D printer equipped with two dispensing syringes (i.e. D1 and D2). We fabricated a 3D cone-shaped structure containing the liquid chocolate syrup as filling (Fig. 7). Figure 7(a) describes the steps to fabricate a 3D structure with filling. Briefly, a 3D cone-shaped enclosure was fabricated using one dispenser (D1), and the empty space within the 3D enclosure was filled with a chocolate syrup using another dispenser (D2). Finally, the remaining portion of the 3D enclosure was fabricated using D1. The final structure contained a liquid chocolate syrup as a filling (Fig. 7(b)). The inside filling can be observed once the enclosure was cut in two pieces (Fig. 7(c)). In this demonstration, we demonstrated that Ci3DP can be readily extended to multi-material food printing. Crucially, this work was enabled simple control over the rheological properties of the chocolate-based inks; two inks possessed different rheological properties at room temperature. The simplicity to prepare printable inks and fabrication of 3D structures at room temperature makes Ci3DP a unique method to perform multi-material food printing. Multi-material food objects consisting of range of liquid materials as fillings such as milk-based products (e.g. cream and yogurt) can be fabricated in a sequential manner using multiple dispensers. Ci3DP should be readily extended to fabricate multi-material food object with higher complexity and self-supporting properties conferred by the properties of the printing ink.

## Conclusions

In this paper, we presented a unique and simple method of direct ink writing (DIW) to fabricate complex 3D structures using chocolate-based materials at room temperature. The process was termed chocolate-based ink 3D printing (Ci3DP) to highlight the importance to formulate inks with adequate rheological properties for DIW. We formulated liquid inks consisting of chocolate-based materials (syrups and pastes) and different concentrations of cocoa powder. The characteristics of the chocolate-based ink were altered from a liquid-like fluid to a solid-like with zero-shear yield stress. The chocolate-based inks were shear-thinning and capable of forming self-supporting layers at room temperature. Our approach bypassed a major requirement of temperature control to perform 3D printing of chocolates by hot-melt extrusion. Ci3DP offered an easy route to fabricate 3D structures of chocolate-based inks with liquid fillings using multiple dispensers.

Ci3DP is flexible and should be capable of fabricating customized food in a wide range of materials with tailored texture and nutritional content. The effect of addition of varying concentrations of cocoa powders in chocolate-based inks on the textural, nutritional and sensorial properties are to be studied. This approach offers an alternative route of 3D modeling of food, especially when food ingredients or additives are sensitive to temperature. The use of multiple nozzles should offer interesting avenues to control distribution of the materials within the printed structure and shall find applications in the design of texture and controlled release of nutrients.

## Methods

### Preparation of inks

We tested three commercially available food syrups and pastes for their suitability of 3D printing. Cake Mate cake icing (Signature Brands, LLC., Florida, USA) was used as it is. The chocolate-based inks were prepared by mixing different concentrations of Hershey’s cocoa powder (Hershey, USA) in (1) Hershey’s chocolate syrup (Hershey, USA) and (2) Nutella hazelnut chocolate spread (Nutella, Singapore). The major ingredients of the cake icing, Hershey’s chocolate syrup and Nutella hazelnut chocolate spread are summarized (Table 1). The formulated chocolate inks were stirred continuously to be homogeneous and then stored in sealed bottles until used for printing.

### Rheological characterization

The measurements of the rheological properties were conducted using a rheometer (Discovery HR-2, TA Instruments, USA) with a 40 mm parallel plate. The gap between the plate and the stationary flatbed was 1000 μm in all the rheological experiments. A spatula was used to deposit the ink carefully on the bottom plate. The top plate was lowered to the set gap of 1000 μm. The excess sample squeezed out between the plates was then removed neatly to avoid the edge effects. Similar loading procedure was followed for all the measurements. All experiments were performed at room temperature and under ambient pressure. Viscosity test were performed by applying a stepwise shear rate ramp from 0.01 to 2000 s−1. A measure of thixotropy of the inks was studied by thixotropy loop test. The applied shear rate was logarithmically increased from 0.0001 to 10 s−1 and then returned back to the initial shear rate at the same time interval. The shear stress versus the shear rate was plotted and the inbound area between upper and lower curve was measured as a measure of thixotropy. Storage modulus (G′) and loss modulus (G′′) were determined by oscillatory stress sweep test by applying sinusoidally varying stresses ranging from 0.1 to 3000 Pa with a constant frequency of 1 Hz. Variation of storage and loss moduli with respect to applied shear stress of the printing inks provided useful information about the sample microstructure. This test allowed determination of linear viscoelastic region (LVR) of the samples. All the data from rheological measurements such as viscosity, yield stress, elastic modulus and thixotropic loop area was reproduced five times and presented as average values with the standard deviation.

### DIW 3D printer

The setup of experiment used in this work is shown in the supplementary information (Supplementary Fig. S1). Inks were deposited using a DIW 3D printer using a commercial 3D printing robot and a dispenser (SHOTmini 200 Sx and IMAGE MASTER 350 PC Smart, Musashi Engineering Inc., Japan). The liquid dispenser was equipped with a single syringe that can be charged with inks with different formulations and was attached with a precise pressure controller (ML-5000XII and ML-808GX, Musashi Engineering Inc., Japan).

### Protocol for Ci3DP

The workflow used to fabricate the 3D printed objects in this study was as follows: MuCAD V software (Musashi Engineering Inc., Japan) was used to generate the design and printed using liquid dispensers. For 3D designs, STL models were obtained freely online (Supplementary Table S1). The STL models were then scaled down and sliced using the Slic3r software into 200–500 µm thick layers to generate the G-code instructions. Then the G-Code was converted into MuCAD V recognizable format by a customized Python script and then sent to the printer. The inks were directly poured into cylindrical dispensing barrels for printing in Ci3DP. The nozzle was attached to the cylindrical ink barrel and placed into its respective position in the liquid dispenser. For every nozzle attached, calibrations in xy- and z- directions (nozzle-to-substrate distance) were performed. The pressure required for the extrusion, dispensing head velocity in each of three directions, dispensing head acceleration and deceleration times were calibrated according to the printing pattern to be fabricated and the viscosity of the ink. The chocolate-based inks were extruded through the attached nozzle to form a filament that was deposited onto the glass substrate in a series of layers. All the experiments were performed at room temperature.

### Imaging

Photographs were taken using a Nikon D5600 camera (Nikon, Japan) and Hirox digital microscope KH-8700 (Hirox Co Ltd., Japan) under white-light illumination. All image processing was done using ImageJ software37.

## References

1. 1.

Yang, W. et al. Carbon nanomaterials in biosensors: Should you use nanotubes or graphene? Angew. Chem. Int. Ed. 49, 2114–2138 (2010).

2. 2.

Farahani, R. D. et al. Direct-write fabrication of freestanding nanocomposite strain sensors. Nanotechnology 23, 085502 (2012).

3. 3.

Karageorgiou, V. & Kaplan, D. Porosity of 3D biomaterial scaffolds and osteogenesis. Biomaterials 26, 5474–5491 (2005).

4. 4.

Hanson Shepherd, J. N. et al. 3D microperiodic hydrogel scaffolds for robust neuronal cultures. Adv. Funct. Mater. 21, 47–54 (2011).

5. 5.

Therriault, D., Shepherd, R. F., White, S. R. & Lewis, J. A. Fugitive inks for direct-write assembly of three-dimensional microvascular networks. Adv. Mater. 17, 395–399 (2005).

6. 6.

Wu, W., DeConinck, A. & Lewis, J. A. Omnidirectional printing of 3D microvascular networks. Adv. Mater. 23, H178–183 (2011).

7. 7.

Voon, S. L., An, J., Wong, G., Zhang, Y. & Chua, C. K. 3D food printing: A categorised review of inks and their development. Virtual Phys. Prototyp. 14, 203–218 (2019).

8. 8.

Tan, C., Toh, W. Y., Wong, G. & Li, L. Extrusion-based 3D food printing - Materials and machines. Int. J. Bioprint. 4, 143 (2018).

9. 9.

Sun, J., Peng, Z., Yan, L., Fuh, J. Y. H. & Hong, G. S. 3D food printing-An innovative way of mass customization in food fabrication. Int. J. Bioprint. 1, 27–38 (2015).

10. 10.

Huang, C. Y. Extrusion-based 3D printing and characterization of edible materials. (University of Waterloo, 2018).

11. 11.

Godoi, F. C., Prakash, S. & Bhandari, B. R. 3D printing technologies applied for food design: Status and prospects. J. Food Engg. 179, 44–54 (2016).

12. 12.

Lipton, J. I. Printable food: The technology and its application in human health. Curr. Opin. Biotechnol. 44, 198–201 (2017).

13. 13.

Hao, L. et al. Material characterisation and process development for chocolate additive layer manufacturing. Virtual Phys. Prototyp. 5, 57–64 (2010).

14. 14.

Dankar, I., Haddarah, A., Omar, F. E. L., Sepulcre, F. & Pujolà, M. 3D printing technology: The new era for food customization and elaboration. Trends Food Sci. Technol. 75, 231–242 (2018).

15. 15.

Beckett, S. T. The science of chocolate. (The Royal Society of Chemistry, Cambridge, UK, 2009).

16. 16.

Windhab, E. J. What makes for smooth, creamy chocolate? Phys. Today 59, 82 (2006).

17. 17.

Afoakwa, E. O., Paterson, A. & Fowler, M. Factors influencing rheological and textural qualities in chocolate – A review. Trends Food Sci. Technol. 18, 290–298 (2007).

18. 18.

Lanaro, M. et al. 3D printing complex chocolate objects: Platform design, optimization and evaluation. J. Food Engg. 215, 13–22 (2017).

19. 19.

Malone, E. & Lipson, H. Fab@Home: the personal desktop fabricator kit. Rapid Prototyp. J. 13, 245–255 (2007).

20. 20.

Mantihal, S., Prakash, S., Godoi, F. C. & Bhandari, B. Optimization of chocolate 3D printing by correlating thermal and flow properties with 3D structure modeling. Innov. Food Sci. Emerg. Technol. 44, 21–29 (2017).

21. 21.

Serenó, L., Vallicrosa, G., Delgado, J. & Ciurana, J. A new application for food customization with additive manufacturing technologies. AIP Conf. Proc. 1431, 825–833 (2012).

22. 22.

Aguado, B. A., Mulyasasmita, W., Su, J., Lampe, K. J. & Heilshorn, S. C. Improving viability of stem cells during syringe needle flow through the design of hydrogel cell carriers. Tissue Eng., Part A 18, 806–815 (2012).

23. 23.

Truby, R. L. & Lewis, J. A. Printing soft matter in three dimensions. Nature 540, 371–378 (2016).

24. 24.

Herschel, W. H. & Bulkley, R. Konsistenzmessungen von Gummi-Benzollösungen. Kolloid Z. 39, 291–300 (1926).

25. 25.

Chaudhuri, A., Wereley, N. M., Radhakrishnan, R. & Choi, S. B. Rheological parameter estimation for a ferrous nanoparticle-based magnetorheological fluid using genetic algorithms. J. Intell. Mater. Syst. Struct. 17, 261–269 (2006).

26. 26.

Costakis, W. J. Jr., Rueschhoff, L. M., Diaz-Cano, A. I., Youngblood, J. P. & Trice, R. W. Additive manufacturing of boron carbide via continuous filament direct ink writing of aqueous ceramic suspensions. J. Eur. Ceram. Soc. 36, 3249–3256 (2016).

27. 27.

Shih, W. Y., Shih, W.-H. & Aksay, I. A. Elastic and yield behavior of strongly flocculated colloids. J. Am. Ceram. Soc. 82, 616–624 (2004).

28. 28.

De Graef, V., Depypere, F., Minnaert, M. & Dewettinck, K. Chocolate yield stress as measured by oscillatory rheology. Food Res. Int. 44, 2660–2665 (2011).

29. 29.

Hyun, K., Kim, S. H., Ahn, K. H. & Lee, S. J. Large amplitude oscillatory shear as a way to classify the complex fluids. J. Non-Newtonian Fluid. 107, 51–65 (2002).

30. 30.

Miller, R. R., Lee, E. & Powell, R. L. Rheology of solid propellant dispersions. J. Rheol. 35, 901–920 (1991).

31. 31.

Ma, L., Xu, J., Coulombe, P. A. & Wirtz, D. Keratin filament suspensions show unique micromechanical properties. J. Biol. Chem. 274, 19145–19151 (1999).

32. 32.

Liu, Z., Zhang, M., Bhandari, B. & Yang, C. Impact of rheological properties of mashed potatoes on 3D printing. J. Food Engg. 220, 76–82 (2018).

33. 33.

Hamilton, C. A. & Alici, G. & in het Panhuis, M. 3D printing Vegemite and Marmite: Redefining “breadboards”. J. Food Engg. 220, 83–88 (2018).

34. 34.

Lille, M., Nurmela, A., Nordlund, E., Metsä-Kortelainen, S. & Sozer, N. Applicability of protein and fiber-rich food materials in extrusion-based 3D printing. J. Food Engg. 220, 20–27 (2018).

35. 35.

Bruneaux, J., Therriault, D. & Heuzey, M.-C. Micro-extrusion of organic inks for direct-write assembly. J. Micromech. Microeng. 18, 115020 (2008).

36. 36.

Martanto, W., Baisch, S. M., Costner, E. A. & Prausnitz, M. R. Fluid dynamics in conically tapered microneedles. AIChE J. 51, 1599–1607 (2005).

37. 37.

Schneider, C. A., Rasband, W. S. & Eliceiri, K. W. NIH Image to ImageJ: 25 years of image analysis. Nat. Methods 9, 671–675 (2012).

## Acknowledgements

The authors thanks International Design Centre (IDC) at Singapore University of Technology and Design (SUTD) for the project support (IDG11700103; Digital Fabrication of Edible Materials). The authors also thank Digital Manufacturing and Design (DManD) Center at SUTD for the shared infrastructure supported by the project (RGDM1620503; Rapid Prototyping Hub).

## Author information

Authors

### Contributions

R.K. and M.H. planned the study. R.K. performed the experiments and analysed the data. R.K. and M.H. wrote the paper.

### Corresponding author

Correspondence to Michinao Hashimoto.

## Ethics declarations

### Competing Interests

The authors declare no competing interests.

Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions

Karyappa, R., Hashimoto, M. Chocolate-based Ink Three-dimensional Printing (Ci3DP). Sci Rep 9, 14178 (2019). https://doi.org/10.1038/s41598-019-50583-5

• Accepted:

• Published:

• ### Semi-solid extrusion 3D printing in drug delivery and biomedicine: Personalised solutions for healthcare challenges

• Iria Seoane-Viaño
• , Patricija Januskaite
• , Carmen Alvarez-Lorenzo
• , Abdul W. Basit
•  & Alvaro Goyanes

Journal of Controlled Release (2021)

• ### Versatile Direct Writing of Aerogel-Based Sol–Gel Inks

• Jianming Yang
• , Hongqiang Wang
• , Bin Zhou
• , Jun Shen
• , Zhihua Zhang
•  & Ai Du

Langmuir (2021)

• ### Development of a Material Mixing Extrusion Type Chocolate 3D Printer

• MinSoo Park
• , HyungJik Jeong
• , JaeHyuek Moon
•  & JungMuk Lim

Journal of the Korean Society for Precision Engineering (2021)

• ### Interpreting rheological behaviour of sugar-fat mixtures as a function of solids phase volume

• Heather M. Shewan
• , Omkar S. Deshmukh
• , Gengning Chen
• , Sophia Rodrigues
• , Nichola Selway
•  & Jason R. Stokes

Journal of Food Engineering (2021)

• ### Printability and performance of 3D conductive graphite structures

• Roneisha Haney
• , Phong Tran
• , Edward B. Trigg
• , Hilmar Koerner
• , Tarik Dickens
•  & Subramanian Ramakrishnan


text:
# Different statement of strong induction proof

1. Dec 3, 2013

### amarch

1. The problem statement, all variables and given/known data

Let m, i be ﬁxed positive integers.

Prove: If we have P(m),P(m+1),...P(m+i) all true and [P(m)∧P(m+1)∧⋯∧P(k)]⟹P(m+1) true for every integer k≥m, then P(n) is true for all integers n≥m .

2. Relevant equations
strong induction, our book defines this as

1) if P(1) is true
2) If (P(1) ∧ P(2) ∧ ... ∧ P(k)) implies P(k+1)
then P(n) is true for all positive integers n.

3. The attempt at a solution

I figured out how to prove it using contradiction and well ordering. Suppose the statement is false, i.e. there exists a least No such that P(No) is false. But we know from the problem statement that P(m)∧P(m+2)∧...∧P(No-1) holds and by the given condition P(No) must also hold, which gives us a contradiction.

...but I was told there is a way to do it using strong induction on n. Isn't the proof trivial because this is just a special case of strong induction, i.e. since we can just set m=1 like in the formal statement of strong induction and let i=0 so that the statement is precisely the statement of strong induction.

Last edited: Dec 3, 2013


text:
## Files in this item

FilesDescriptionFormat

application/pdf

9702460.pdf (6MB)
(no description provided)PDF

## Description

 Title: A kinematic and abundance survey in the galactic rotational directions Author(s): Bell, David James Doctoral Committee Chair(s): Yoss, Kenneth M. Department / Program: Astronomy Discipline: Astronomy Degree Granting Institution: University of Illinois at Urbana-Champaign Degree: Ph.D. Genre: Dissertation Subject(s): Physics, Astronomy and Astrophysics Abstract: Photometric and spectroscopic observations have been obtained for 1028 G and K-type stars near the cardinal directions corresponding to Galactic rotation and anti-rotation. The spectra have been used to obtain radial velocities by cross-correlation, and estimates of stellar metallicity via a spectrophotometric index. The DDO and BV photometric observations yield estimates of distance, color excess, spectral type and metallicity. Reddening trends as a function of distance are found to be consistent with previous investigations in each of the two directions. An extracted subsample of 570 late-type giants has been used with maximum likelihood modeling to study the kinematic and abundance characteristics of the local Galactic disk. The data are well represented by a two-component disk model in which the "thick disk" has a mean abundance of $-0.35 \pm 0.06$, an asymmetric drift of $43 \pm 9$ km s$\sp{-1}$, and a local normalization of $13 \pm 3$%. A continuous "extended disk" model is also fitted to the data, but is found to be significantly inferior through a likelihood ratio test.The discrete nature supports disk-formation models in which the thick disk is created by a separate distinguishable process relative to the thin disk, such as through a merger event early in the disk's history. It is less consistent with models in which the thick disk forms through continuous processes, such as during a dissipational disk collapse or through secular kinematic diffusion of stars from a thin-disk configuration into a thick one. Issue Date: 1996 Type: Text Language: English URI: http://hdl.handle.net/2142/22561 ISBN: 9780591087864 Rights Information: Copyright 1996 Bell, David James Date Available in IDEALS: 2011-05-07 Identifier in Online Catalog: AAI9702460 OCLC Identifier: (UMI)AAI9702460


text:
# The mathematics of surprise, part 1

I’ve split this post into two parts because it would be really long otherwise. Part 2 will be coming up later, hopefully.

### Surprisingness

Let’s think about how we might define surprisingness as a mathematical quantity.

Surprisingness is a property of events as perceived by observers. After the event occurs, the observer is surprised to a certain degree. The degree of surprisingness depends on how likely the observer thought it was that the event would occur, or to put it briefly the subjective probability of the event. In fact, to a reasonable approximation, at least, the degree of surprisingness depends only on the subjective probability of the event. The greater the subjective probability, the less the surprise.

For example, if you flip a coin and it comes up heads, this is not very surprising—the probability of this event was only $1/2$, which is reasonably high. But if you flip ten coins and they all come up heads, you are much more surprised, due to the fact that the probability of ten heads in ten flips is only

$\displaystyle \left( \frac 1 2 \right)^{10} = \frac 1 {1024}.$

This is a much smaller quantity than $1/2$, hence the large increase in surprise. Even if you are unable to do the calculation and work out that the probability of ten heads in ten flips is exactly $1/1024$, you are probably aware on an intuitive level that it is a lot smaller than $1/2$.

These considerations suggest surprisingness might be definable as a mapping $S$ on $[0, 1]$ (the set of the real numbers between 0 and 1, inclusive), such that for every $p \in [0, 1]$ (i.e. every member $p$ of $[0, 1]$), the value $S(p)$ is the common surprisingness of the events of subjective probability $p$. Listed below are three properties such a mapping $S$ should have, if it is to be in accordance with the everyday meaning of “surprise”.

Property 1. For every $p \in [0, 1]$ (i.e. every member $p$ of $[0, 1]$), the value $S(p)$ should be a non-negative real number, or $+\infty$ (positive infinity).

Justification. Surprisingness seems to be reasonably well-modelled as (to use statistics jargon) an interval variable: two surprisingness values can be compared to see which is less and which is greater, there is a sensical notion of “distance” between surprisingness values, etc. Therefore, it makes sense for surprisingness to be represented by a real number. Moreover, there is a natural minimum surprisingness, namely the surprisingness of an event of subjective probability 1 (i.e. which the observer was sure would happen)—such an event is not at all surprising, and it makes sense to speak of being, e.g., “twice as surprised” by one event compared to another with reference to this natural minimum. To use statistics jargon again, surprisingness is a ratio variable. Naturally, it makes sense to set the minimum value at 0.

Property 2. The mapping $S$ should be strictly decreasing. That is, for every pair $p, q$ of members of $[0, 1]$ such that $p < q$, we should have $S(q) < S(p)$.

Justification. As said above, events of high subjective probility are less surprising than those of low subjective probability.

Property 3. For every pair $p, q$ of members of $[0, 1]$, we should have $S(pq) = S(p) + S(q).$

Justification. Suppose $A$ and $B$ are independent events of subjective probabilities $p$ and $q$ respectively. Then, assuming subjective probabilities are assigned in a consistent way, obeying the laws of probability, the subjective probability of $A \cap B$ (the event that both $A$ and $B$ occur) is $pq$ and therefore the surprisingness of $A \cap B$ is $S(pq)$. But given that $A$ and $B$ are independent (so the observation of one does not change the observer’s subjective probability of the other), the surprisingness of $A \cap B$ overall, i.e. $S(pq)$, should be the same as the total surprisingness of the individual observations of $A$ and $B$, i.e. $S(p) + S(q)$.

Remarkably, these three properties determine the form of $S$ almost exactly (up to a vertical scale factor). Feel free to skip the proof below; it is somewhat long and tedious and doesn’t use any ideas that will be used later on in the post, and I haven’t put in much effort to make it easy to follow.

Theorem 1. The mappings $S$ on $[0, 1]$ having properties 1–3 above are those of the form $p : [0, 1] \mapsto -\log_b p$ (i.e. those mappings $S$ on $[0, 1]$ such that $S(p) = - \log_b p$ for every $p \in [0, 1]$), where $b$ is a real number greater than 1.

Proof. Suppose $S$ is a mapping on $[0, 1]$ having properties 1–3 above. Let $f$ be the composition of $S$ and $x : \mathbb R \mapsto e^x$. Then the domain of $f$ is the set of the $x \in \mathbb R$ such that $0 \le e^x \le 1$, i.e. $x \le 0$; and for every pair $x, y$ of non-positive real numbers, we have

\begin{aligned} f(x, y) &= S(e^{x + y}) \\ &= S(e^x e^y) \\ &= S(e^x) + S(e^y) \\ &= f(x) + f(y). \end{aligned}

In the case where $x = y = 0$, we see that $f(0 + 0) = f(0) + f(0)$, and we also have $f(0 + 0) = f(0)$ because $0 + 0 = 0$, so combining the two we have $f(0) = f(0) + f(0)$, from which it follows by subtraction of $f(0)$ from both sides that $0 = f(0)$. Similarly, for every non-positive $x \in \mathbb R$ and every non-negative $n \in \mathbb Z$ (the set $\mathbb Z$ is the set of the integers) we have $f((n + 1) x) = f(nx + x) = f(nx) + f(x)$, and if we assume as an inductive hypothesis that $f(nx) = nf(x)$ it follows that $f((n + 1) x) = (n + 1) f(x)$. This proves by induction that $f(nx) = nf(x)$.

Now, let $c = f(-1)$. For every non-positive $x \in \mathbb Q$ (the set $\mathbb Q$ is the set of the rational numbers), there is a non-positive $m \in \mathbb Z$ and a positive $n \in \mathbb Z$ such that $x = m/n$, and therefore

\begin{aligned} nf(x) &= nf \left( \frac m n \right) \\ &= f(m) \\ &= f((-m)(-1)) \\ &= (-m)f(-1) \\ &= -mc, \end{aligned}

from which it follows that $f(x) = -mc/n = -cx$.

The equation $f(x) = -cx$ in fact holds for every non-positive $x \in \mathbb R$, not just for $x \in \mathbb Q$. To prove this, first, observe that $f$ is strictly decreasing, because for every pair $x, y$ of non-positive real numbers such that $x < y$, we have $e^x < e^y$ and therefore $f(y) = S(e^y) < S(e^x) = f(x)$ (the mapping $S$ being strictly decreasing by property 2). Second, suppose $x$ is a non-positive real number and $f(x) \ne -cx$. Then $-f(x)/c \ne x$, i.e. either $-f(x)/c < x$ (case 1) or $x < -f(x)/c$ (case 2). Because every non-empty interval contains a rational number, it follows that there is an $a \in \mathbb Q$ such that $-f(x)/c < a < x$ (in case 1) or $x < a < -f(x)/c$ (in case 2).

In both cases, we have $a \le 0$. This is obvious in case 1, because $x \le 0$. As for case 2, observe first that $S$ is non-negative-valued and therefore $-f(x) \le 0$. If $c$ is positive, it will then follow that $-f(x)/c \le 0$ and therefore $a \le 0$ (because $a < -f(x)/c$). To prove that $c$ is positive, observe that $S$ is strictly decreasing, and we have $f(1) = c$, i.e. $S(1/e) = c$, and $f(0) = 0$, i.e. $S(1) = 0$.

Because $a \le 0$ in both cases, we have $f(a) = -ca$. And by the strict decreasingness of $f$ it follows that either $f(x) < -ca$ (in case 1) or $-ca < f(x)$ (in case 2). Rearranging these two inequalities gives us $a < -f(x)/c$ (in case 1) or $-f(x)/c < a$ (in case 2). But we already have $-f(x)/c < a$ (in case 1) or $a < -f(x)/c$ (in case 2), so in both cases there is a contradiction. It follows that $f(x) \ne -cx$ cannot hold; we must have $f(x) = -cx$.

Finishing off, note that for every $p \in [0, 1]$, we have $S(p) = S(e^{\log p}) = f(\log p) = -c \log p$. Let $b = e^{1/c}$; then $b > 1$ because $c > 0$, and $\log b = 1/c$, i.e. $c = 1/(\log b)$, from which it follows that $S(p) = -(\log p)/(\log b) = -\log_b p$ for every $p \in [0, 1]$. From this we can conclude that for every mapping $S$ on $[0, 1]$ such that properties 1–3 hold, we have

$\displaystyle S = p : [0, 1] \mapsto -\log_b p,$

where $b$ is a real number greater than 1. $\blacksquare$

In the rest of this post, suppose $b$ is a real number greater than 1. The surprisingness mapping $S$ will be defined by

$\displaystyle S = p : [0, 1] \mapsto -\log_b p.$

It doesn’t really make any essential difference to the nature of $S$ which value of $b$ is chosen, because for every $p \in [0, 1]$, we have $S(p) = -\log_b p = -(\log p)/(\log b)$ (where the $\log$ symbol with no base specified refers to the natural logarithm, the one to base $e$), and therefore the choice of base amounts to a choice of vertical scaling. Below are three plots of surprisingness against probability for three different bases (2, $e$ and 10); you can see that the shape of the graph is the same for each base, but the vertical scaling is different.

Note that regardless of the choice of base, we have

\begin{aligned} S(1) &= -\log_b 1 = -0 = 0, \\ S(0) &= -\log_b 0 = -(-\infty) = \infty. \end{aligned}

That is, events thought sure to occur are entirely unsurprising, and events thought sure not to occur are infinitely surprising when they do happen.

Also,

$\displaystyle S \left( \frac 1 b \right) = -\log_b \left( \frac 1 b \right) = -(-1) = 1.$

I’m inclined to say on this basis that 2 is the most sensible choice of base, because of all the possible probabilities other than 0 and 1, the one which is most special and thus most deserving of corresponding to the unit surprisingness is probably $1/2$, the probability exactly halfway between 0 and 1. However, base $e$ is also quite convenient because it simplifies some of the formulae we’ll see later on in this post.

### Entropy

First, two basic definitions from probability theory (for readers who may not be familiar with them). Suppose $A$ is a finite set.

Definition 1. The probability distributions on $A$ are the positive real-valued mappings $f$ on $A$ such that

$\displaystyle (1) \quad \sum_{x \in A} f(x) = 1.$

The probability distributions on $A$ can be thought of as random generators of members of $A$. Each member of $A$ is generated with probability equal to the positive real number less than or equal to 1 associated with that member. The probabilities of generation for each member have to add up to 1, and this is expressed by equation (1). Note that the requirement that the probabilities add up to 1 implies the requirement that the probabilities are each less than or equal to 1, so there is no need to explicitly state the latter requirement in the definition.

Henceforth, suppose $f$ is a probability distribution on $A$.

Definition 2. For every real-valued mapping $\tau$ on $A$, the expected value or mean $\mathrm E_f(\tau)$ of the transformation of $f$ by $\tau$ is given by the formula

$\displaystyle (2) \quad \mathrm E_f(\tau) = \sum_{x \in A} f(x) \tau(x).$

Let $x_1$, $x_2$, … and $x_n$ be the members of $A$ and let $p_1 = f(x_1)$, $p_2 = f(x_2)$, … and $p_n = f(x_n)$. Then for every real-valued mapping $\tau$ on $A$, the expected value $\mathrm E_f(\tau)$ is the weighted average of $\tau(x_1)$, $\tau(x_2)$, … and $\tau(x_n)$, with the weights the respective probabilities $p_1$, $p_2$, … and $p_n$.

If a very large number $N$ of values are generated (independently) by $f$, then the average value under $\tau$ of these values can be calculated as

$\displaystyle \frac 1 N \sum_{k = 1}^n f_k \tau(x_k) = \sum_{k = 1}^n \frac {f_k} N \tau(x_k),$

where $f_1$, $f_2$, … and $f_n$ are the frequencies of the values $x_1$, $x_2$, … and $x_n$ in the sample. Given that $N$ is very large it is very likely that the relative frequencies $f_1/N$, $f_2/N$, … and $f_n/N$ will be close to $p_1$, $p_2$, … and $p_n$, respectively, and therefore the average will be close to $\mathrm E_f(\tau)$.

Now, the definition of the key concept of this post:

Definition 3. The expected surprisingness or entropy $\mathrm H_f$ (that’s the Greek capital letter eta, not the Latin capital letter H) of $f$ is $\mathrm E_f(S \circ f)$ (here, $S \circ f$ is the composition of $S$ and $f$, i.e. $x : A \mapsto S(f(x))$).

The use of the word “entropy” here is closely related to the use of the same word in thermodynamics. However, I won’t go into the connection here (I don’t really know enough about thermodynamics to be able to talk intelligently about it).

Having the concept of entropy to hand gives us a fun new question we can ask about any given probability distribution: what is its entropy, or, more evocatively, how surprising is it?

By (2), we have

$\displaystyle (3) \quad \mathrm H_f = \sum_{x \in A} f(x) S(f(x)).$

Using the definition of $S$, this can also be written as

$\displaystyle (4) \quad \mathrm H_f = -\sum_{x \in A} f(x) \log_b f(x).$

Using logarithm properties, it can even be written as

$\displaystyle \quad \mathrm H_f = \log_b \frac 1 {\prod_{x \in A} f(x)^{f(x)}}.$

This shows that $\mathrm H_f$ is the logarithm of the reciprocal of

$(5) \quad \displaystyle \prod_{x \in A} f(x)^{f(x)},$

which is the geometric weighted average of $p_1$, $p_2$, … and $p_n$, with the weights being identical to the values averaged. A geometric weighted average is similar to an ordinary weighted average, except that the values averaged are multiplied rather than added and the weights are exponents rather than factors. The product (5) can therefore be thought of as the “expected probability” of the value generated by $f$. To the extent that $f$ is likely to generate one of the members of $A$ which has a low individual probability of being generated, the product (5) is small and accordingly $\mathrm H_f$ is large. This may help give you a slightly more concrete idea why $\mathrm H_f$ can be thought of as the expected surprisingness of $f$.

Note that the value of $\mathrm H_f$ is determined completely by the probabilities $p_1$, $p_2$, … and $p_n$. The values $x_1$, $x_2$, … and $x_n$ are irrelevant in and of themselves. This is evident from the formula (3), in which the expression $x$ only appears as a sub-expression of $f(x)$. To understand how $\mathrm H_f$ is determined by these probabilities, it helps to look at the graph of the mapping $p : (0, 1] \mapsto p S(p)$, which I have plotted below. The entropy $\mathrm H_f$ is a sum of exactly $n$ values of this mapping.

It can be seen from the graph that the mapping has a maximum value. Using calculus, we can figure out what this maximum value is and exactly where it is attained.

Theorem 1. The maximum value attained by $p : [0, 1] \mapsto p S(p)$ is $1/b$, and this maximum is attained at the point $1/b$ (and nowhere else).

Proof. The derivative of $p : (0, +\infty) \mapsto p (-\log_b p)$ is $p : (0, +\infty) \mapsto -(1 + \log_b p)$ (by the product rule), which is positive if $p < 1/b$ (because then $\log_b p < -1$), equal to 0 if $p = 1/b$ (because then $\log_b p = -1$), and negative if $p > 1/b$ (because then $\log_b p > -1$). Therefore $p : (0, \infty) \mapsto p (-\log_b p)$ increases in value from the vicinity of 0 to $1/b$ and decreases in value from $1/b$ towards $+\infty$, which means it attains a minimum at $1/b$. $\blacksquare$

Because $\mathrm H_f$ is a sum of $n$ values of $p : [0, 1] \mapsto p S(p)$, we may conclude that the inequality

$\displaystyle \mathrm H_f \le \frac n b$

always holds. However, this upper bound on the value of $H_f$ can be improved, as we’ll see below. After all, in proving that it holds we’ve made no use of equation (1).

### Cross entropy

The concept of cross entropy is a useful generalization of the concept of entropy.

Suppose $g$ another probability distribution on $A$. Think of $f$ and $g$ as two different models of the random member-of-$A$ generator: $f$ is the right model (or a more right model, if you don’t like the idea of one single right model), and $g$ is an observer’s working model. The probabilities $p_1$, $p_2$, … and $p_n$ can be thought of as the real probabilities of generation of $x_1$, $x_2$, … and $x_n$, respectively, while the probabilities $q_1 = g(x_1)$, $q_2 = g(x_2)$, … and $q_n = g(x_n)$ can be thought of as the observer’s subjective probabilities. Although the real probabilities determine what the observer observes, the subjective probabilities are what determine how surprised the observer is by what they observe. Therefore, if the observer calculates entropy by averaging their surprisingness over a large number of observations, they will get something close to

$\displaystyle \sum_{k = 1}^n p_k S(q_k),$

i.e. $\mathrm E_f(S \circ g)$. This quantity is called the cross entropy from $g$ to $f$ and denoted $\mathrm H(f, g)$. Note that if $f = g$ then $\mathrm H(f, g) = \mathrm H(f) = \mathrm H(g)$; that’s why the concept of cross entropy is a generalization of the concept of entropy. Note also that $\mathrm H(f, g)$ is not necessarily the same as $\mathrm H(g, f)$.

Your intuition should tell you that $\mathrm H(f, g)$ will always be greater than $\mathrm H(f)$, if $f \ne g$. Why? Think about it: $\mathrm H(f, g)$ is the expected surprisingness if the observer has the wrong model, $\mathrm H(f, f)$ is the expected surprisingness if the observer has the right model. Having the right model should lead to the observer being better able to predict which member of $A$ is generated and thus to the observer being less likely to be surprised.

It is indeed the case that

$\displaystyle (6) \quad \mathrm H(f, g) > \mathrm H(f)$

if $\mathrm f \ne g$ (which further reassures us that $S$ is a very good mathematical model of the intuitive notion of surprisingness). The inequality (6) is called Gibbs’ inequality. In order to prove it, first, observe that it may be rewritten as

$\displaystyle (7) \quad \mathrm H(f, g) - \mathrm H(f) > 0.$

Now, the quantity on the left-hand side of (7) has a name of its own: it’s called the Kullback-Leibler divergence from $g$ to $f$ and denoted $\mathrm D(f, g)$. It measures the “penalty” in increased surprisingness the observer gets for having the wrong model; it can also be thought of as a measure of how different the probability distributions $f$ and $g$ are from each other, hence the name “divergence”. As for the “Kullback-Leibler” part, that’s just because mathematicians have come up with lots of different ways of measuring how different two probability distributions are from each other and Kullback and Leibler were the mathematicians who came up with this particular measure. I won’t be referring to any other such measures in this post, however, so whenever I need to refer to Kullback-Leibler divergence again I’ll just refer to it as “divergence”.

So Gibb’s inequality, reformulated, states that the divergence between two unequal probability distributions is always positive. To prove this, it’s helpful to first write out an explicit expression for $\mathrm D(f, g)$:

\displaystyle \begin{aligned} \mathrm D(f, g) &= \mathrm H(f, g) - \mathrm H(f) \\ &= \sum_{x \in A} f(x) S(g(x)) - \sum_{x \in A} f(x) S(f(x)) \\ &= \sum_{x \in A} f(x) (S(g(x)) - S(f(x)) \\ &= \sum_{x \in A} f(x) (\log_b f(x) - \log_b g(x)) \\ &= \sum_{x \in A} f(x) \log_b \frac {f(x)} {g(x)}. \end{aligned}

Second, we prove a lemma.

Lemma 1. For every positive $x \in \mathbb R$, we have $\log_b x \ge (x - 1)/(x \log b)$, where $\log b$ is the natural logarithm (logarithm to base $e$) of $b$, with equality if and only if $x = 1$.

Proof. The inequality in question is equivalent to $\log x \ge (x - 1)/x$ (by multiplication of both sides by $\log b$). The right-hand side of this inequality is equal to $1 - 1/x$. Consider the mapping $x : (0, +\infty) \mapsto \log x - (1 - 1/x)$. The derivative of this mapping is $x : (0, +\infty) \mapsto 1/x - 1/x^2$, which is negative if $x < 1$ (because then $x^2 < x$ and therefore $1/x < 1/x^2$), equal to 0 if $x = 1$ (because then $x^2 = x$) and positive if $x > 1$ (because then $x^2 > x$ and therefore $1/x > 1/x^2$). Therefore $x : (0, +\infty) \mapsto \log x - (1 - 1/x)$ is strictly decreasing on $(0, 1)$ and strictly increasing on $(1, +\infty)$. It follows that its minimum value is attained at the point $1$. And that minimum value is $\log x - (1 - 1/x) = 0 - (1 - 1) = 0 - 0 = 0$. $\blacksquare$

Using Lemma 1, we have

$\displaystyle (8) \quad \log_b \frac {f(x)} {g(x)} \ge \frac {f(x)/g(x) - 1} {(f(x)/g(x)) \log b} = \frac {f(x) - g(x)} {f(x) \log b}$

for every $x \in A$, with equality if and only if $f(x)/g(x) = 1$, i.e. $f(x) = g(x)$. Given that $f \ne g$, there is at least one $x \in A$ such that $f(x) \ne g(x)$ and therefore (8) holds without equality. It follows that

\begin{aligned} \mathrm D(f, g) &> \sum_{x \in A} f(x) \frac {f(x) - g(x)} {f(x) \log b} \\ &= \frac 1 {\log b} \sum_{x \in A} (f(x) - g(x)) \\ &= \frac 1 {\log b} \left( \sum_{x \in A} f(x) - \sum_{x \in A} g(x) \right) \\ &= \frac {1 - 1} {\log b} \\ &= 0, \end{aligned}

which proves Gibbs’ inequality.

Gibbs’ inequality is quite powerful and useful. For example, it can be used to figure out what the maximum possible entropy is. Suppose $g$ is such that $\mathrm H(f, g) = \mathrm H(g)$, regardless of the value of $f$. Then if $f \ne g$, we have $\mathrm H(g) > \mathrm H(f)$ by Gibbs’ inequality, and therefore $\mathrm H(g)$ is the maximum entropy possible for probability distributions on $A$ and $g$ is the unique probability distribution on $A$ whose entropy is $\mathrm H(g)$. Is there a probability distribution $g$ on $A$ such that $\mathrm H(f, g) = \mathrm H(g)$, regardless of the value of $f$? There is indeed. Let $g$ be the uniform distribution on $A$, i.e. the mapping $x : A \mapsto 1/n$ (remember, $n$ is the number of members $A$ has). Then

$\displaystyle \sum_{x \in A} g(x) = \frac n n = 1$

so $g$ is a probability distribution, and regardless of the value of $f$ we have

\begin{aligned} \mathrm H(f, g) &= \sum_{x \in A} f(x) \left(-\log_b \frac 1 n \right) \\ &= \left( \sum_{x \in A} f(x) \right) \log_b n \\ &= \log_b n. \end{aligned}

Therefore, the maximum entropy possible on $A$ is $\log_b n$, and the uniform distribution on $A$ is the probability distribution which attains this maximum.

A consequence of this is that the divergence of $f$ from the uniform distribution on $A$ is given by

$\displaystyle \mathrm D(f, g) = \mathrm H(f, g) - \mathrm H(f) = \log_b - \mathrm H(f)$

which is just the negation of $\mathrm H(f)$ plus a constant $\log_b n$ (well, a constant depending on the size of the set $A$ which $f$ is distributed over). Therefore, among probability distributions on $A$ specifically, entropy can be thought of as a measure of divergence from the uniform distribution. Among probability distributions in general, entropy is a measure of both divergence from the uniform distribution and the size of the distributed-over set.

### Philosophical implications

So far, we’ve seen that the informal concept of surprisingness can be formalized mathematically with quite a high degree of success—one might even say a surprising degree of success, which is fitting—and that’s pretty neat. But there are also some deeper philosophical issues related to all this. I’ve avoided talking about them up till now because philosophy is not really my field, but I couldn’t let them go completely unmentioned.

Suppose that you know that one of $n$ values $x_1$, $_2$, … and $x_n$ values (where $n$ is a positive integer) will be generated by some probability distribution $f$, but you don’t know the probabilities; you have absolutely no information about the probability distribution other than the set of values it may generate. What should your subjective probability distribution be? A possible answer to this question is that you shouldn’t have one—you simply don’t know the probabilities, and that’s all that can be said. And that’s reasonable enough, especially if you don’t like the concept of subjective probability or think it’s incoherent (e.g. if you’re a strict frequentist when it comes to interpreting probability). But if you accept that subjective probabilities are things it makes sense to talk about, well, the whole point of subjective probabilities is that they represent states of knowledge under uncertainty, so there’s no reason in principle to avoid having a subjective probability distribution just because this particular state of knowledge is particularly uncertain. Of course this subjective probability distribution may change as you gather more information—think of it as your “best guess” to start with, to be improved later on.

There are some people who’d say that you can choose your initial “best guess” on an essentially arbitrary basis, according to your own personal whims. No matter which subjective probability distribution you choose to start with, it will get better and better at modelling reality as you change it as you gather more information; the initial state isn’t really important. The initial state is of interest only in that if we have some updating mechanism in mind, we’d like to be able to prove that convergence to the real probability distribution will always happen independently of the initial state.

There is another position which can be taken, however, which is that there is in fact a certain objectively best subjective probability distribution to start with. This position is associated with the marquis de Laplace (1749–1827), who wrote a classic text on probability theory, the Théorie analytique des probabilités (Laplace was also a great contributor to many other fields of mathematics, as mathematicians back then tended to be—they didn’t do specialization back then). In Laplace’s opinion, the correct distribution to start with was the uniform distribution. That is, given that we know nothing about the probabilities, assume they are all the same (after all, we have no reason to believe any one is larger than any other). This principle is called the principle of indifference.

The concept of probability as a whole can be based on the idea of the principle of indifference. The idea would be that on some level, any probability distribution is over a set of interchangeable values and therefore uniform. However, we are often interested only in whether one of a particular class of values is generated (not in which particular member of that class) and the probability of interest in that case is the sum of the probabilities of each of the values in that class, which, because the underlying distribution is uniform, can also be expressed as the ratio of the number of values in the class to the total number of values which may be generated. I don’t know how far this is how Laplace thought of probability; I don’t want to be too hasty to attribute views to a 19th-century author which might be out of context or just incorrect (after all, I can’t read French so all my information about Laplace is second-hand).

It’s not hard to argue with the principle of indifference. It’s quite difficult to think of any reasonable justification for it at all. It was indeed attacked in vehement terms by later probability theorists, such as John Venn (1834–1923) (that’s right, the Venn diagram guy). In modern times, however, it has been championed by the statistical physicist E. T. Jaynes (1922–1998), who also came up with an interesting extension of it.

In the mathematical section of this post, we saw that the uniform distribution over $x_1$, $x_2$, … and $x_n$ was the one with the most entropy, i.e. the one which is “most surprising on average”. Therefore, a natural generalization of the principle of indifference would be to say that in any circumstance in which a subjective probability distribution must be assumed in a situation of uncertainty, one should assume whichever distribution has the most entropy while still being compatible with what is known. For example, if it is known what the mean is then the assumed distribution should be the one with the most entropy among all distributions having that specific mean. This is called the principle of maximum entropy or MaxEnt for short.

The MaxEnt principle makes sense intuitively, sort of, in a way that the principle of indifference on its own doesn’t. If you don’t know something about the probability distribution, you should expect to be surprised more often by the values it generates than if you do know that something. It’s still on fairly shaky ground, though, and I don’t know how far it is accepted by people other than Jaynes as a normative principle, as opposed to just one way in which you might choose the subjective probability distribution to start with, in competition with other ways of doing so on the basis of strictly pragmatic considerations (which seems to be how a lot of people in the practical applications side of things view it). In any case it gives us a philosophical motivation for examining the mathematical problem of finding the probability distributions that have the most entropy given particular constraints. The mathematical problem is interesting itself, but the philosophical connection makes it more interesting.

In part 2 of this post, I’m going to describe how the famous normal distribution can be characterized as a maximum entropy distribution: namely, if it’s the normal distribution with mean $\mu$ (a real number) and standard deviation $\sigma$ (a positive real number), then it’s the absolutely probability distribution over $\mathbb R$ with the most entropy among all absolutely continuous probability distributions over $\mathbb R$ with mean $\mu$ and standard deviation $\sigma$. That roughly means that by MaxEnt, if you know nothing about a continuous probability distribution other than that it has a particular mean and a particular standard deviation, your best guess to start with is that it’s normal. You can understand the famous Central Limit Theorem from that perspective: as you add up independent, identically distributed random variables, the mean and variance of the distribution in question will be carried over into the sum (elementary statistical theory tells us that the mean of any sum of random variables is the sum of the individual means, and the variance of any sum of independent random variables is the sum of the individual variances), but every other distinctive property of the distribution is gradually kneaded out by the summing process, so that as the sum gets larger and larger all we can say about the probability distribution of the sum is that it has this particular mean and this particular variance. I intend to finish off part 2 with a proof of the Central Limit theorem from this perspective, although that might be a little ambitious. Before that, though, the other big thing which I need to cover in part 2 is defining entropy in the case of a continuous probability distribution—I’ve only been talking about discrete probability distributions in part 1, and it turns out the extension is not entirely a straightforward matter.


text:
# Finding and editing dead code with Coco

Finding and editing dead code with Coco

As part of the coverage report, Coco generates a list of lines with dead code. One would often like to remove these lines, but when they are spread over a large project, it requires some effort to navigate the editor to them. This can be made easier with a lesser-known feature of the cmreport program, which is part of Coco. With cmreport, it is possible to edit these lines one by one in a text editor or an IDE. The same idea can be used for other tasks.

The idea behind it is based on the fact that many editors and IDEs can read the output of the compiler – especially the error messages and warnings – and jump to the places in the code which they refer to. We can use this feature and let cmreport generate output that looks like compiler error messages and points to the lines with dead code.

To do this we use the text output format of cmreport. Mostly one uses cmreport to generate HTML reports, but there is also a line-oriented plain text format that is ideally suited to generate imitated compiler error messages.

### A script to generate error messages in the Unix format

The format for error messages differs between Unix-like systems and Windows. We will start with the Unix format. In Unix, compiler error messages look like /path/to/file.cpp:55:12: Some error message, where the first number is a line number and the second one the column number at which the error occurs.

The following shell script creates a list of dead code locations in the same format:

#! /bin/bash
#
# Usage: deadcode.sh file.csmes

COCODIR=/opt/SquishCoco/bin
${COCODIR}/cmreport -m "$1" --text= --format-dead-code='%f:%l:%c: %m'

It requires that Coco is installed in the standard location, at /opt/SquishCoco. If it is not, the variable COCODIR must be changed. (And do not forget to make the script executable with « chmod +x deadcode.sh« !)

The script has one parameter, which is a .csmes file. cmreport reads this file, extracts lines with dead code in it and writes them to the standard output. To do this, the following options are used:

• -m specifies the .csmes file to read. Here it is the first parameter of the script, which is enclosed in quotation marks to handle file paths with spaces correctly.
• –text specifies that the output format is text. There is no output file given after the « = » sign, which means that the output of cmreport appears on the standard output stream.
• –format-dead-code specifies the output format for lines with dead code. There are no other format specification flags given, therefore cmreport will only report dead code lines. The format string contains the following escape sequences:
• %f stands for the full path to the file,
• %l is the line number of the line,
• %c the column number, and finally
• %e is a short description of the line. In case of dead code it starts with the words « dead code:  » and then continues with the content of the line.

Together these flags let cmreport produce an output in the same format as a C/C++ compiler.

### Use with the parser example

The parser example in the tutorial that comes with Coco contains a few lines of dead code. We can therefore use our script to find them.

First we need to generate an instrumented version of the parser, to get a .csmes file, in our case parser.csmes. Running the parser is not necessary, it is enough to compile it with « ./instrumented make -f gmake.mak distclean parser« .

We will use is the Emacs editor to edit the source code. Emacs has a compile command, which usually is used to run compilation commands like make. We need to run our deadcode.sh script instead, in the way that is displayed at the right. The way it is displayed here, the deadcode.sh script must be located in the same directory as the file parser.csmes, and the compile command must be run from a file that is in the same directory as there files. If that does not work in your case, try to use full paths for the script and he .csmes file.

The result is shown at the right. At the bottom one sees the output of the script showing that the file parser.cpp contains five lines of dead code. Emacs has already opened the file automatically and placed the cursor at the beginning of the first line with dead code.

### A script for Windows

Under windows, error messages have a different format. They look like C:\path\to\file.cpp(55): Some error message, with the line number in braces. This needs different command line parameters for cmreport and we also should better write the script that generates the fictitious error messages as a Windows batch file.

The result is shown below; the most important difference to the Unix version is due to the fact that the percent sign plays a special role in the batch file syntax; to get the right output we need to use double percent signs in the format string. We also need to be aware that Coco may also be installed in the directory C:\Program Files (x86)\squishcoco; if that is the case, the variable COCODIR needs to be changed.

@echo off
REM Usage: deadcode.cmd file.csmes

set "COCODIR=C:\Program Files\squishcoco"
"%COCODIR%\cmreport" -m %1 --text= --format-dead-code="%%f(%%l): %%m"

### Use with Visual Studio

Users who prefer Emacs can use the script in the same way as on Unix, but what do those who prefer Visual Studio? One possibility here is to use the « External Tools » feature of Visual Studio.

To create an external tool that generates a list of dead code lines, one needs to select the entry « External tools… » in the « Tools » menu. A dialog window appears, in which a new entry for « Dead code » must be entered as shown in the image at the right. In the « Commands » and « Arguments » fields, full path names are needed; for « Arguments », the variable \$(TargetDir) often evaluates to an useful path prefix for the .csmes file.

Among the checkboxes, the most important one is that for « Use Output window », which directs the script output to the compiler output window of Visual Studio: Clicking on error messages in this window directs the editor to the place in the code to which they refer.

The only disadvantage of this method is that it has the .csmes file built in, which could be annoying when the project changes. As a remedy, the checkbox « Prompt for arguments » is here also selected: It allows to enter a different .csmes file, if necessary.