Posts whose title or text contains one of these words are left out of every view.
Whole words only: ai catches "AI-generated" but not "openai". Add a star for word beginnings: llm* catches llm and llms.
99 words is the limit
https://www.johndcook.com/blog
188 posts · 17 Votes · 1 Followers
Science 49% · Tech 40% · Writing 5% · Culture 3% · Life 1% · Art 1% · 2 more 1%
Subscribe via RSS
The previous post gave a simple and accurate approximation for the smaller angle of a right triangle. Given a right triangle with sides a, b, and c, where a is the shortest side and c is the hypotenuse, the angle opposite side a is approximately in radians. The previous post worked in degrees, but here we’ll use radians. If the triangle is oblique rather than a right triangle, there an approximation for the angle A that doesn’t require inverse trig functions, though it does require square…
Suppose you have a right triangle with sides a, b, and c, where a is the shortest side and c is the hypotenuse. Then the following approximation from [1] for the angle A opposite side a seems too simple and too accurate to be true. In degrees, A ≈ a 172° / (b + 2c). The approximation above only involves simple arithmetic. No trig functions. Not even a square root. It could be carried out with pencil and paper or even mentally. And yet it is surprisingly accurate. If we use the 3, 4, 5 triangle…
AI coding agents improved greatly last summer, and again last December-January. Here are my experiences since my last post on the subject. The models feel subjectively much smarter. They can accomplish a much broader range of tasks. They seem to have a larger, more comprehensive in-depth view of the code base and what you are trying to accomplish. They can locate more details in obscure parts of the code related to the specific task at hand. By rough personal estimate, I would say that they…
A few days ago I wrote a post on Newton’s diameter theorem. The theorem says to plot the curve formed by the solutions to f(x, y) = 0 where f is a polynomial in x and y of degree n. Next plot several parallel lines that cross the curve at n points and find the centroid of the intersections on each line. Then the centroids will fall on a line. The previous post contained an illustration using a cubic polynomial and three evenly spaced parallel lines. This post uses a fifth degree polynomial, and…
The previous post looked at the FP4 4-bit floating point format. This post will look at another 4-bit floating point format, NF4, and higher precision analogs. NF4 and FP4 are common bitsandbytes 4-bit data types. If you download LLM weights from Hugging Face quantized to four bits, the weights might be in NF4 or FP4 […] The post Gaussian distributed weights for LLMs first appeared on John D. Cook.
In ancient times, floating point numbers were stored in 32 bits. Then somewhere along the way 64 bits became standard. The C programming language retains the ancient lore, using float to refer to a 32-bit floating point number and double to refer to a floating point number with double the number of bits. Python simply […] The post 4-bit floating point FP4 first appeared on John D. Cook.
Let f(x, y) be an nth degree polynomial in x and y. In general, a straight line will cross the zero set of f in n locations [1]. Newton defined a diameter to be any line that crosses the zero set of f exactly n times. If f(x, y) = x² + y² − 1 then the zero set of f is a circle and diameters of the […] The post Newton diameters first appeared on John D. Cook.
If you know the distance d to a satellite, you can compute a circle of points that passes through your location. That’s because you’re at the intersection of two spheres—the earth’s surface and a sphere of radius d centered on the satellite—and the intersection of two spheres is a circle. Said another way, one observation […] The post Intersecting spheres and GPS first appeared on John D. Cook.
The Wikipedia article on modern triangle geometry has an image labled “Artz parabolas” with no explanation. A quick search didn’t turn up anything about Artz parabolas, but apparently the parabolas go through pairs of vertices with tangents parallel to the sides. The derivation is a little complicated, but here’s code that will find the parameters […] The post Finding a parabola through two points with given slopes first appeared on John D. Cook.
Andrzej Odrzywolek recently posted an article on arXiv showing that you can obtain all the elementary functions from just the function and the constant 1. The following equations, taken from the paper’s supplement, show how to bootstrap addition, subtraction, multiplication, and division from the elm function. See the paper and supplement for how to obtain […] The post The smallest math library first appeared on John D. Cook.
The date of Easter The church fixed Easter to be the first Sunday after the first full moon after the Spring equinox. They were choosing a date in the Roman (Julian) calendar to commemorate an event whose date was known according to the Jewish lunisolar calendar, hence the reference to equinoxes and full moons. The […] The post Lunar period approximations first appeared on John D. Cook.
Today is Orthodox Easter. Western churches celebrated Easter last week. Why are the Eastern and Western dates of Easter different? Is Eastern Easter always later than Western Easter? How far apart can the two dates be? Why the dates differ Easter is on the first Sunday after the first full moon in Spring. East and […] The post The gap between Eastern and Western Easter first appeared on John D. Cook.
There’s a lot of mathematics just off the beaten path. You can spend a career in math and yet not know all there is to know about even the most basic areas of math. For example, this post will demonstrate something you may not have seen about decimal forms of fractions. Let p > 5 […] The post Distribution of digits in fractions first appeared on John D. Cook.
Saw a post on X saying that the latitude of the Pyramid of Giza is the same as the speed of light. I looked into this, expecting it to be approximately true. It’s exactly true in the sense that the speed of light in vacuum is 299,792,458 m/s and the line of latitude 29.9792458° N […] The post The Great Pyramid of Giza and the Speed of Light first appeared on John D. Cook.
I recently ran across a post on X describing a process for creating a random fractal. First, pick a random point c inside a hexagon. Then at each subsequent step, pick a random side of the hexagon and create the triangle formed by that side and c. Update c to be the center of the new triangle […] The post Random hexagon fractal first appeared on John D. Cook.
I recently found out about Andrica’s conjecture: the square roots of consecutive primes are less than 1 apart. In symbols, Andrica’s conjecture says that if pn and pn+1 are consecutive prime numbers, then √pn+1 − √pn < 1. This has been empirically verified for primes up to 2 × 1019. If the conjecture is true, […] The post Root prime gap first appeared on John D. Cook.
Last week I wrote about the orbit of Artemis II. The orbit of Artemis I was much more interesting. Because Artemis I was unmanned, it could spend a lot more time in orbit. The Artemis I mission took 25 days while Artemis II will take 10 days. Artemis I took an unusual path, orbiting the […] The post A Three- and a Four- Body Problem first appeared on John D. Cook.
Landauer’s principle gives a lower bound on the amount of energy it takes to erase one bit of information: E ≥ log(2) kB T where kB is the Boltzmann constant and T is the ambient temperature in Kelvin. The lower bound applies no matter how the bit is physically stored. There is no theoretical lower […] The post All you need is Tofolli gates first appeared on John D. Cook.
The best way to run AI and remain HIPAA compliant is to run it locally on your own hardware, instead of transferring protected health information (PHI) to a remote server by using a cloud-hosted service like ChatGPT or Claude. [1]. There are HIPAA-compliant cloud options, but they’re both restrictive and expensive. Even enterprise options are […] The post HIPAA compliant AI first appeared on John D. Cook.
This post will look at the problem of updating an average grade as an very simple special case of Bayesian statistics and of Kalman filtering. Suppose you’re keeping up with your average grade in a class, and you know your average after n tests, all weighted equally. m = (x1 + x2 + x3 + […] The post Kalman and Bayes average grades first appeared on John D. Cook.
I used the term perilune in yesterday’s post about the flight path of Artemis II. When Artemis is closest to the moon it will be furthest from earth because its closest approach to the moon, its perilune, is on the side of the moon opposite earth. Perilune is sometimes called periselene. The two terms come from […] The post Roman moon, Greek moon first appeared on John D. Cook.
I was looking through an old geometry book [1] and saw a hyperbolic analog of Napier’s mnemonic for spherical trigonometry. In hindsight of course there’s a hyperbolic analog: there’s a hyperbolic analog of everything. But I was surprised because I’d never thought of this before. I suppose the spherical version is famous because of its […] The post Hyperbolic version of Napier’s mnemonic first appeared on John D. Cook.
The Artemis II mission launched yesterday. Much like the Apollo 8 mission in 1968, the goal is to go around the moon in preparation for a future mission that will land on the moon. And like Apollo 13, the mission will swing around the moon rather than entering lunar orbit. Artemis II will deliberately follow […] The post Artemis II, Apollo 8, and Apollo 13 first appeared on John D. Cook.
Pentagonal numbers are truncated triangular numbers. You can take the diagram that illustrates the nth pentagonal number and warp it into the base of the image that illustrates the (2n − 1)st triangular number. If you added a diagram for the (n − 1)st triangular number to the bottom of the image on the right, you’d […] The post Pentagonal numbers are truncated triangular numbers first appeared on John D. Cook.
I’m skeptical that quantum computing will become practical in the next 100 years. However, if it does become practical and we don’t prepare, the world’s financial system could collapse. Everyone agrees we should prepare for quantum computing, even those of us who doubt it will be practical any time soon. Quantum computers exist now, but […] The post Quantum Y2K first appeared on John D. Cook.
Peter Vogel posted the following image on X yesterday. The receive side of the coin is a decision tree for decoding Morse code. The shape is what makes this one interesting. Decision trees are typically not very compact. Each branch is usually on its own horizontal level, with diagonal lines going down from each node […] The post Morse code tree first appeared on John D. Cook.
While shopping on a major e-commerce site, I wanted to get an answer to an obscure question about a certain product. Not finding the answer immediately on the product page, I thought I’d try clicking the AI shopping assistant helper tool to ask this question. I waited with anticipation for an answer I would expect […] The post An AI Odyssey, Part 3: Lost Needle in the Haystack first appeared on John D. Cook.
Suppose you have a calculator or math library that only handles real arguments but you need to evaluate sin(3 + 4i). What do you do? If you’re using Python, for example, and you don’t have NumPy installed, you can use the built-in math library, but it will not accept complex inputs. >>> import math >>> […] The post Computing sine and cosine of complex arguments with only real functions first appeared on John D. Cook.
I alluded to Lebesgue constants in the previous post without giving them a name. There I said that the bound on order n interpolation error has the form where h is the spacing between interpolation points and δ is the error in the tabulated values. The constant c depends on the function f being interpolated, and to a […] The post Lebesgue constants first appeared on John D. Cook.
Richard Feynman said that almost everything becomes interesting if you look into it deeply enough. Looking up numbers in a table is certainly not interesting, but it becomes more interesting when you dig into how well you can fill in the gaps. If you want to know the value of a tabulated function between values […] The post How much precision can you squeeze out of a table? first appeared on John D. Cook.