F
Feed Atlas
OPML directory + server-side RSS reader

johndcook.com

SiteRSSBlogs
Back

Latest posts

  • Calculating curvature
    May 08, 2026John

    Curvature is conceptually simple but usually difficult to calculate. For a level set curve f(x, y) = c, such as in the previous couple posts, the equation for curvature is Even when f has a fairly simple expression, the expression for κ can be complicated. If we define then the level set of f(x, y) = c is […] Calculating curvature first appeared on John D. Cook.

  • Smoothed polygons
    May 07, 2026John

    The previous post constructed a triangular analog of the squircle, the unit circle in the p-norm where p is typically around 4. The case p = 2 is a Euclidean circle and the limit as p → ∞ is a Euclidean square. The previous post introduced three functions Li(x, y) such that the level set of each function forms […] Smoothed polygons first appeared on John D. Cook.

  • Triangular analog of the squircle
    May 06, 2026John

    TimF left a comment on my guitar pick post saying the image was a “squircle-ish analog for an isosceles triangle.” That made me wonder what a more direct analog of the squircle might be for a triangle. A squircle is not exactly a square with rounded corners. The sides are continuously curved, but curved most […] Triangular analog of the squircle first appeared on John D. Cook.

  • Unified config files
    May 06, 2026John

    I try to maintain a consistent work environment across computers that I use. The computers differ for important reasons, but I’d rather they not differ for unimportant reasons. Unified keys One thing I do is remap keys so that the same key does the same thing everywhere, to the extent that’s practical. This requires remapping […] Unified config files first appeared on John D. Cook.

  • The mythology of category theory
    May 06, 2026John

    Yesterday a friend and I had a conversation about category theory, how it can be a useful pattern description language, but also about how people have unrealistic expectations for it, believing category theory can deliver something for nothing. Later I ran across the following post from Qiaochu Yuan. It felt as if he had overheard […] The mythology of category theory first appeared on John D. Cook

  • Changing one character in a PDF
    May 05, 2026John

    I saw a post on X saying Changing a hyphen to an en-dash increases your PDF file size by ~10 bytes. My first thought was that it had something to do with hyphen being an ASCII character and an en-dash not. Changing a hyphen to an en-dash would make a UTF-8 encoded text file a […] Changing one character in a PDF first appeared on John D. Cook.

  • The shape of a guitar pick
    May 03, 2026John

    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 shape of a guitar pick first appeared on John D. Cook.

  • Approximating even functions by powers of cosine
    May 01, 2026John

    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 […] Approximating even functions by powers of cosine first appeared on John

  • Three ways to differentiate ReLU
    Apr 30, 2026John

    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 […] Three ways to differentiate ReLU first app

  • Turning a trick into a technique
    Apr 28, 2026John

    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 […] Turning a trick into a technique first appeared on John D. Cook.

  • Circular arc approximation
    Apr 28, 2026John

    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θ, […] Circular arc approximation first appeared on John D. Cook.

  • Closed-form solution to the nonlinear pendulum equation
    Apr 25, 2026John

    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 […] Closed-form solution to the nonlinear pendulum equation first appeared o

  • nth derivative of a quotient
    Apr 25, 2026John

    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. […] nth derivative of a quotient first appeared on John D. Cook.

  • How nonlinearity affects a pendulum
    Apr 24, 2026John

    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 […] How nonlinearity affects a pendulum first appeared on John D. Cook.

  • Approximation to solve an oblique triangle
    Apr 23, 2026John

    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 […] Approximation to solve an oblique triangle first appeared on John

  • Simple approximation for solving a right triangle
    Apr 23, 2026John

    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 […] Simple approximation for solving a right triangle first appeared on John D. Cook.

  • An AI Odyssey, Part 4: Astounding Coding Agents
    Apr 21, 2026Wayne Joubert

    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 […] An AI Odyssey, Part 4: Astounding Coding Agents first appeared on Jo

  • More on Newton’s diameter theorem
    Apr 20, 2026John

    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 […] More on Newton’s diameter theorem first appeared on John D. Cook.

  • Gaussian distributed weights for LLMs
    Apr 18, 2026John Cook

    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 […] Gaussian distributed weights for LLMs first appeared on John D. Cook.

  • 4-bit floating point FP4
    Apr 18, 2026John 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 […] 4-bit floating point FP4 first appeared on John D. Cook.

  • Newton diameters
    Apr 16, 2026John 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 […] Newton diameters first appeared on John D. Cook.

  • Intersecting spheres and GPS
    Apr 14, 2026John

    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 […] Intersecting spheres and GPS first appeared on John D. Cook.

  • Finding a parabola through two points with given slopes
    Apr 14, 2026John

    The Wikipedia article on modern triangle geometry has an image labeled “Artzt parabolas” with no explanation. A quick search didn’t turn up anything about Artzt parabolas [1], 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² […] Finding a parabola through two points with given slopes first appeared

  • Mathematical minimalism
    Apr 13, 2026John

    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 eml function. See the paper and supplement for how to obtain […] Mathematical minimalism first appeare

  • Lunar period approximations
    Apr 12, 2026John

    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 […] Lunar period approximations first appeared on John D. Cook.

  • The gap between Eastern and Western Easter
    Apr 12, 2026John

    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 [1]. East […] The gap between Eastern and Western Easter first appeared on John D. Cook.

  • Distribution of digits in fractions
    Apr 10, 2026John

    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 […] Distribution of digits in fractions first appeared on John D. Cook.

  • The Great Pyramid of Giza and the Speed of Light
    Apr 09, 2026John

    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 Great Pyramid of Giza and the Speed of Light first appeared on John D. Cook.

  • Random hexagon fractal
    Apr 09, 2026John

    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 […] Random hexagon fractal first appeared on John D. Cook.

  • Root prime gap
    Apr 09, 2026John

    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, […] Root prime gap first appeared on John D. Cook.