Convexity and equality in Jensen inequality Theorem 3.3 from W. Rudin, Real and complex analysis, says:
Let $\mu$ be a probabilistic measure on a $\sigma$-algebra of subsets of a given set $\Omega$.
If a function  $f:X \rightarrow \mathbb R$ is in $L^1(\mu)$, $a<f(x)<b$ for $x\in \Omega$ and if a function $\phi:(a,b)\rightarrow \mathbb R$  is a convex  then
$$
\phi\left(\int_a^b fd \mu\right) \leq \int_a^b (\phi \circ f) d \mu.
$$
Is it known when in  this inequality holds equality?
Maybe, it is iff $\phi$ is affine a.e. ?
 A: We can look at the proof to see when equality occurs.
The convexity of $\phi$ gives us
$$\lambda := \sup_{a < s < c} \frac{\phi(c)-\phi(s)}{c-s} \leqslant \rho := \inf_{c < t < b} \frac{\phi(t)-\phi(c)}{t-c}$$
for every $c\in (a,b)$. Letting $c := \int_X f\,d\mu$, it follows that for every $\kappa \in [\lambda,\rho]$ and $t\in (a,b)$ we have
$$\phi(t) \geqslant \phi(c) + \kappa\cdot (t-c)\tag{1}$$
and hence
$$\phi(f(x)) \geqslant \phi(c) + \kappa\cdot \bigl(f(x) - c\bigr)\tag{2}$$
for every $x\in X$. Integrating $(2)$ gives Jensen's inequality, and it follows that we have the equality
$$\int_X \phi\circ f\,d\mu = \phi\left(\int_X f\,d\mu\right)$$
if and only if we have equality a.e. in $(2)$.
That we have equality a.e. in $(2)$ means that $\phi$ coincides with an affine function on [the convex hull of] the essential range of $f$, but $\phi$ need not be affine globally on $(a,b)$.
If $f$ is essentially constant, that is no restriction on $\phi$, then equality holds in Jensen's inequality for all $\phi$. If $\phi$ is affine, we have equality for all $f$. If $\phi$ is strictly convex, Jensen's inequality is strict for all $f$ except the essentially constant ones, but if $\phi$ is not strictly convex, equality also holds for some (essentially) non-constant $f$.
A: Not sure if this helps (but if you are interested in relations between convexity inequalities, and the which such inequalities collapse into, or approximate equality conditions) see, and the cited works
p2; in Bingham, N. H.; Ostaszewski, A. J., Cauchy's functional equation and extensions: Goldie's equation and inequality, the Go{\l}\c{a}b-Schinzel equation and Beurling's equation, Aequationes Math. 89, No. 5, 1293-1310 (2015). ZBL1331.26003.
and in particular.
Kuczma, Marek, An introduction to the theory of functional equations and inequalities. Cauchy's equation and Jensen's inequality. Edited by Attila Gil\'anyi, Basel: Birkh\"auser (ISBN 978-3-7643-8748-8/pbk). xiv, 595~p. (2009). ZBL1221.39041..
I apologize if this not relevant.
