We show that for positive semidefinite A and B the relative entropy can be written as D(A\|B)=2\int a\log(a/b)\,d\mu_{A,B}(a,b), where \mu_{A,B} denotes Hein\"avaara's tracial joint spectral measure. This allows us to obtain a unified
We show that for positive semidefinite A and B the relative entropy can be written as D(A\|B)=2\int a\log(a/b)\,d\mu_{A,B}(a,b), where \mu_{A,B} denotes Hein\"avaara's tracial joint spectral measure. This allows us to obtain a unified derivation of several known integral representations of relative entropy from scalar equalities. Scalar inequalities can be used in the same way to derive Pinsker-type bounds. We further show that the testing curve t\mapsto tr[A-tB]_+ is piecewise affine exactly when A and B commute, which is equivalent to their testing region being a polygon. This gives a characterization of noncommutativity through the curvature. As further applications, we derive inequalities for relative entropy variance and the loss of relative entropy under positive trace-preserving maps.