I just received the 4th edition copy of Physically Based Rendering[0]. Donald Knuth wrote "This book has deservedly won an Academy Award. I believe it should also be nominated for a Pulitzer Prize."
It is a 1200 page literate program. It not only contains the actual source code, it contains complete explanations of the physical theory and the implementation ideas. This textbook is used in a various upper-class and graduate programs. I can highly recommend it. I had hoped that Axiom could have been reborn as a literate program. The idea was to "make it live beyond the authors". Each algorithm would provide an explanation, various literature references, and some examples as well as limitations. That way a person with no background knowledge in computer algebra could learn and contribute. Such a literate program would have set the standard for mathematical software. Sadly that's not going to happen. Tim [0] Matt Pharr, Wenzel Jakob, and Greg Humphreys "Physically Based Rendering" https://www.pbr-book.org/