I saw a post on X that plotted the function (log x)² + (log y)² = 1. Of course the plot of x² + y² = 1 is a circle, but I never thought what taking logs would do to the shape. Here’s what the contours look like setting the right hand side equal to 1, 2, […] The post The shape of a guitar pick first appeared on John D. Cook .
John D. Cook
A couple days ago I wrote a post about turning a trick into a technique, finding another use for a clever way to construct simple, accurate approximations. I used as my example approximating the Bessel function J(x) with (1 + cos(x))/2. I learned via a helpful comment on Mathstodon that my approximation was the first-order […] The post Approximating even functions by powers of cosine first appear…
approximationmathematicsnumerical-methods
When a function is not differentiable in the classical sense there are multiple ways to compute a generalized derivative. This post will look at three generalizations of the classical derivative, each applied to the ReLU (rectified linear unit) function. The ReLU function is a commonly used activation function for neural networks. It’s also called the […] The post Three ways to differentiate ReLU…

aimachine-learning
Someone said a technique is a trick that works twice. I wanted to see if I could get anything interesting by turning the trick in the previous post into a technique. The trick created a high-order approximation by subtracting a multiple one even function from another. Even functions only have even-order terms, and by using […] The post Turning a trick into a technique first appeared on John D. Co…

Suppose you have an arc a, a portion of a circle of radius r, and you know two things: the length c of the chord of the arc, and the length b of the chord of half the arc, illustrated below. Here θ is the central angle of the arc. Then the length of the arc, rθ, […] The post Circular arc approximation first appeared on John D. Cook .

geometrymathematics
The previous post looks at the nonlinear pendulum equation and what difference it makes to the solutions if you linearize the equation. If the initial displacement is small enough, you can simply replace sin θ with θ. If the initial displacement is larger, you can improve the accuracy quite a bit by solving the linearized […] The post Closed-form solution to the nonlinear pendulum equation first …
calculusdifferential-equationsmathematics
There’s a nice formula for the nth derivative of a product. It looks a lot like the binomial theorem. There is also a formula for the nth derivative of a quotient, but it’s more complicated and less known. We start by writing the quotient rule in an unusual way. Applying the quotient rule twice gives the following. […] The post nth derivative of a quotient first appeared on John D. Cook .
calculusmathematics
The equation of motion for a pendulum is the differential equation where g is the acceleration due to gravity and ℓ is the length of the pendulum. When this is presented in an introductory physics class, the instructor will immediately say something like “we’re only interested in the case where θ is small, so we can […] The post How nonlinearity affects a pendulum first appeared on John D. Cook .
mechanicsphysics
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 […] The post Approximation to solve an oblique triangle first appeare…
mathematicstrigonometry
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 […] The post Simple approximation for solving a right triangle first appeared on John D…
geometrymathematics
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 […] The post An AI Odyssey, Part 4: Astounding Coding Agents first appe…
aimachine-learningnlp
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 […] The post More on Newton’s diameter theorem first appeared on John D. Cook .
geometrymathematics
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. Coo…
aimachine-learning
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 .
computer-scienceprogramming-languages
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 .
algebramathematics
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 .
geometrymathematics
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 general form of a conic section is ax² + bxy + cy² + […] The post Finding a parabola through two points with given slopes first app…
geometrymathematics
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 Mathematical minimalism fir…
algebramathematics
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. C…
research.ioSign up to keep scrolling
Create your feed subscriptions, save articles, keep scrolling.
Already have an account?
