R Posner, Economic Analysis of the Law (8th edn, Aspen, 2011) 151 Paul Davies. JC Smith's The Law of Contract (2018 2 ed). p. 6.

On a slightly diﬀerent tack, but in a similar vein, Judge Richard Posner has written:17

Suppose I sign a contract to deliver 100,000 custom-ground widgets at \$.10 apiece to A, for use
    in his boiler factory. After I have delivered 10,000, B comes to me, explains that he desperately
    needs 25,000 custom-ground widgets at once since otherwise he will be forced to close his pianola factory at great cost, and offers me \$.15 apiece for 25,000 widgets. I sell him the widgets
    and as a result do not complete timely delivery to A, who sustains \$1000 in damages from my
    breach. Having obtained an additional profit of \$1250 on the sale to B, I am better off even
    after reimbursing A for his loss. Society is also better off. Since B was willing to pay me \$.15
    per widget, it must mean that each widget was worth at least \$.15 to him. But it was worth only
    \$.14 to A—\$.10, what he paid, plus \$.04 ($1000 divided by 25,000), his expected profit. Thus the
    breach resulted in a transfer of the 25,000 widgets from a lower valued to a higher valued use.

17 R Posner, Economic Analysis of the Law (8th edn, Aspen, 2011) 151.



*

*Pls ELI5. Where does this key equation spring from? I wouldn't have thought to create this to deduce the break-even price?


$(x - \$0.10) \times 100,000 = (x - \$0.10) \times \color{red}{75,000} + 1,000$


*Where's the $\color{red}{\$75,000}$ from?

 A: Answering your questions in reverse order, because it's easier :)


*

*The $75,000$ is not in dollars, it's in widgets.  $100,000$ widgets were contracted for, and $25,000$ were sold to B, leaving $75,000$ to be delivered to A.

*The equation is the mathematical form of the question "What value does A ascribe to each widget?"  We know that A has agreed to buy the widgets for $\$0.10$ each, and that A intends to make a profit, so we also know that the value of the widget to A is greater than $\$0.10$ -- i.e. that A (at least) believes the widget can be sold for more (albeit as part of something else, such as the pianolas that B sells).  So, the true value of the widget to A is our unknown: $x$.  We know that A incurred $\$1000$ damages as a result of not receiving $25,000$ widgets, so we can calculate the value of $x$.
A intended to sell $100,000$ objects made using widgets that cost $\$0.10$ each, so the profit he would receive on that sale (from widgets alone) is $(x-0.10) \times 100,000$.
A actually sold $75,000$ objects using those widgets at $\$0.10$ each, and incurred damages of $\$1000$ from not having $25,000$ widgets.  So if $A$ had had those missing $25,000$ widgets they would not have incurred damages and would have $\$1000$ instead.  So A's actual situation would have been $(x-0.10)\times 75,000 + 1000$ -- sale of $75,000$ objects plus damages not incurred.
Setting these things equal to one another allows us to solve for $x$ -- which turns out to be $0.14$, which is the true value to A of the widget.  Which, unluckily for A, is $\$0.01$ less than the value of those widgets to B (at least when he's in a rush).
