Feed john-d-cook John D. Cook

Favorite IconJohn D. Cook

Link https://www.johndcook.com/blog
Feed http://feeds.feedburner.com/TheEndeavour?format=xml
Updated 2024-11-21 21:48
Expert witness experiences
The world of expert testimony seems mysterious from the outside, so I thought some readers would find it interesting to have a glimpse inside. Kinds of experts There are two kinds of experts, consulting experts and testifying experts. These names mean what they say: consulting experts consult with their clients, and testifying experts testify. Usually […]The post Expert witness experiences first appeared on John D. Cook.
Eliminating terms from higher-order differential equations
This post ties together two earlier posts: the previous post on a change of variable to remove a term from a polynomial, and an older post on a change of variable to remove a term from a differential equation. These are different applications of the same idea. A linear differential equation can be viewed as […]The post Eliminating terms from higher-order differential equations first appeared on John D. Cook.
How to depress a general polynomial
This post showed how to do a change of variables to remove the quadratic term from a cubic equation. Here we will show that the technique works more generally to remove the xn-1 term from an nth degree polynomial. We will use big-O notation O(xk) to mean terms involving x to powers no higher than […]The post How to depress a general polynomial first appeared on John D. Cook.
How to solve a cubic equation
The process for solving a cubic equation seems like a sequence of mysterious tricks. I’d like to try to make the steps seem a little less mysterious. Depressed cubic The previous post showed how to reduce a general cubic equation to one in the form which is called a “depressed cubic.” In a nutshell, you […]The post How to solve a cubic equation first appeared on John D. Cook.
How to depress a cubic
The title of this post sounds like the opening to a bad joke: How do you depress a cubic? … Insert your own punch line. A depressed cubic is a simplified form of a cubic equation. The odd-sounding terminology suggests that this is a very old idea, older than the current connotation of the word […]The post How to depress a cubic first appeared on John D. Cook.
New SI prefixes and their etymology
Five months ago I wrote a post speculating about new SI prefixes. I said in this post “There’s no need for more prefixes; this post is just for fun.” Well, truth is stranger than fiction. There are four new SI prefixes. These were recently approved at the 27th General Conference on Weights and Measures. Here […]The post New SI prefixes and their etymology first appeared on John D. Cook.
Calculating sine to an absurd number of digits
Suppose you wanted to calculate sin(x) to a million decimal places using a Taylor series. How many terms of the series would you need? You can use trig identities to reduce the problem to finding sin(x) for |x| ≤ 1. Let’s take the worst case and assume we want to calculate sin(1). The series for […]The post Calculating sine to an absurd number of digits first appeared on John D. Cook.
Simple example of Kleisli composition
When a program needs to work with different systems of units, it’s best to consistently use one system for all internal calculations and convert to another system for output if necessary. Rigidly following this convention can prevent bugs, such as the one that caused the crash of the Mars Climate Orbiter. For example, maybe you […]The post Simple example of Kleisli composition first appeared on John D. Cook.
Getting pulled back in
“Just when I thought I was out, they pull me back in.” — Michael Corleone, The Godfather, Part 3 My interest in category theory goes in cycles. Something will spark my interest in it, and I’ll dig a little further. Then I reach my abstraction tolerance and put it back on the shelf. Then sometime […]The post Getting pulled back in first appeared on John D. Cook.
Exploring bad passwords
If your password is in the file rockyou.txt then it’s a bad password. Password cracking software will find it instantly. (Use long, randomly generated passwords; staying off the list of worst passwords is necessary but not sufficient for security.) The rockyou.txt file currently contains 14,344,394 bad passwords. I poked around in the file and this […]The post Exploring bad passwords first appeared on John D. Cook.
When a cubic or quartic has a double root
Thanks to the quadratic equation, it’s easy to tell whether a quadratic equation has a double root. The equation has a double root if and only if the discriminant is zero. The discriminant of a cubic is much less known, and the analogs for higher order polynomials are unheard of. There is a discriminant for […]The post When a cubic or quartic has a double root first appeared on John D. Cook.
Entropy of a Student t distribution
I was looking up the entropy of a Student t distribution and something didn’t seem right, so I wanted to look at familiar special cases. The Student t distribution with ν degrees of freedom has two important special cases: ν = 1 and ν = ∞. When ν = 1 we get the Cauchy distribution, […]The post Entropy of a Student t distribution first appeared on John D. Cook.
Solving quadratic trig equations
A few days ago I wrote about how to systematically solve trig equations. That post was abstract and general. This post will be concrete and specific, looking at the special case of quadratic equations in sines and cosines, i.e. any equation of the form As outlined earlier, we turn the equation into a system of equations […]The post Solving quadratic trig equations first appeared on John D. Cook.
Simultaneous root-finding
In 1891 Karl Weierstrass developed a method for numerically finding all the roots of a polynomial at the same time. True to Stigler’s law of eponymy this method is known as the Durand-Kerner method, named after E. Durand who rediscovered the method in 1960 and I. Kerner who discovered it yet again in 1966. The […]The post Simultaneous root-finding first appeared on John D. Cook.
Mercator and polar projections
This post is a more quantitative version of the previous post. Before I said that straight lines on a Mercator projection map correspond to loxodrome spirals on a sphere. This post will make that claim more explicit. So suppose we plot a straight path from Quito to Jerusalem on a Mercator projection. The red dot […]The post Mercator and polar projections first appeared on John D. Cook.
Straight on a map or straight on a globe?
Straight lines on a globe are not straight on a map, and straight lines on a map are not straight on a globe. A straight line on a globe is an arc of a great circle, the shortest path between two points. When projected onto a map, a straight path looks curved. Here’s an image […]The post Straight on a map or straight on a globe? first appeared on John D. Cook.
Elliptic coordinates and Laplace’s equation
In rectangular coordinates, constant values of x are vertical lines and constant values of y are horizontal lines. In polar coordinates, constant values of r are circles and constant values of θ are lines from the origin. In elliptic coordinates, the position of a point is specified by two numbers, μ and ν. Constant values […]The post Elliptic coordinates and Laplace’s equation first appeared on John D. Cook.
Computing arccos
Suppose you take two numbers, a and b, and repeatedly take their arithmetic mean and their geometric mean. That is, suppose we set a0 = a b0 = b then a1 = (a0 + b0)/2 b1 = √(a0 b0) and repeat this process, each new a becoming the arithmetic mean of the previous a and […]The post Computing arccos first appeared on John D. Cook.
Three diagrams
This post will give examples of three similar diagrams that occur in three dissimilar areas: design of experiments, finite difference methods for PDEs, and numerical integration. Central Composite Design (CCD) The most popular design for fitting a second-order response surface is the central composite design or CCD. When there are two factors being tested, the […]The post Three diagrams first appeared on John D. Cook.
Carlson’s elliptic integrals
Although its a little fuzzy to say exactly which functions are “special” functions, these are generally functions that come up frequently in applications, that have numerous symmetries, and that satisfy many useful identities. The copious interconnections between special functions that are part of what makes them special also makes these functions hard to organize: everything […]The post Carlson’s elliptic integrals first appeared on John D. Cook.
Kinds of elliptic integrals
There are three fundamental kinds of elliptic integrals, and these are prosaically but unhelpfully called elliptic integrals of the first kind, the second kind, and the third kind. These names sound odd to modern ears, but it’s no different than classical musicians naming symphonies Symphony No. 1, Symphony No. 2, etc. This post covers the […]The post Kinds of elliptic integrals first appeared on John D. Cook.
Three interesting curves
Here are three curves that have interesting names and interesting shapes. The fish curve The fish curve has parameterization x(t) = cos(t) – sin²(t)/√2 y(t) = cos(t) sin(t) We can plot this curve in Mathematica with ParametricPlot[ {Cos[t] - Sin[t]^2/Sqrt[2], Cos[t] Sin[t]}, {t, 0, 2 Pi}] to get the following. It’s interesting that the image […]The post Three interesting curves first appeared on John D. Cook.
What is a Pentanomial GFSR random number generator?
The ISO random number generation standard, ISO 28640, speaks of a “Pentanomial GFSR method” for generating random variates. What is this? We’ll break it down, starting with GFSR. GFSR In short, a GFSR random number generator is what is now more commonly called a linear feedback shift register, or LFSR. The terminology “GFSR” was already […]The post What is a Pentanomial GFSR random number generator? first appeared on John D. Cook.
Systematically solving trigonometric equations
Students are asked to solve trigonometric equations shortly after learning what sine and cosine are. By some combination of persistence and luck they may be able to find a solution. After proudly presenting the solution to a teacher, the teacher may ask “Is that the only solution?” A candid student would respond by saying “How […]The post Systematically solving trigonometric equations first appeared on John D. Cook.
Nephroids and evolutes
The previous post looked at the evolute of an ellipse. This post will look at evolutes more generally, and then look at nephroids. As a quick reminder, given a curve curve c, a point on its evolute is the center of curvature for a point on c. See the previous post for a detailed example. […]The post Nephroids and evolutes first appeared on John D. Cook.
Evolute of an ellipse
Suppose you’re standing on an ellipse. (You actually are: lines of longitude are elliptical because of earth’s equatorial bulge.) Now draw a line perpendicular to where you’re standing. Lines of longitude are nearly circles, but we’ll look at a more obviously elliptical ellipse. The line is perpendicular to the northeast side of the ellipse where […]The post Evolute of an ellipse first appeared on John D. Cook.
Newton’s method: The Good, The Bad, and The Ugly
This post will give examples where Newton’s method gives good results, bad results, and really bad results. Our example problem is to solve Kepler’s equation M = E – e sin E for E, given M and e, assuming 0 ≤ M ≤ π and 0 < e < 1. We will apply Newton’s method […]The post Newton’s method: The Good, The Bad, and The Ugly first appeared on John D. Cook.
Uniform sampling from an ellipse
There is a simple way to randomly sample points from an ellipse, but it is not uniform. Assume your ellipse is parameterized by with t running from 0 to 2π. The naive approach would be to take uniform samples from t and stick them into the equations above. Rather than looking at random sampling, this […]The post Uniform sampling from an ellipse first appeared on John D. Cook.
How to calculate length of an elliptic arc
This post will show how to find the length of piece of an ellipse and explain what elliptic integrals have to do with ellipses. Assume we have an ellipse centered at the origin with semi-major axis a and semi-minor axis b. So a > b > 0, the longest diameter of the ellipse is 2a […]The post How to calculate length of an elliptic arc first appeared on John D. Cook.
Python code to solve Kepler’s equation
The previous post looked at solving Kepler’s equation using Newton’s method. The problem with using Newton’s method is that it may not converge when the eccentricity e is large unless you start very close to the solution. As discussed at the end of that post, John Machin came up with a clever way to start […]The post Python code to solve Kepler’s equation first appeared on John D. Cook.
Solving Kepler’s equation with Newton’s method
In the introduction to his book Solving Kepler’s Equation Over Three Centuries, Peter Colwell says In virtually every decade from 1650 to the present there have appeared papers devoted to the Kepler problem and its solution. This is remarkable because Kepler’s equation isn’t that hard to solve. It cannot be solved in closed form using […]The post Solving Kepler’s equation with Newton’s method first appeared on John D. Cook.
The world is lumpy
The Pareto principle, or the 80-20 rule, says that 80% of output comes from 20% of inputs. For example, maybe the top 20% of salesmen generate 80% of a company’s revenue. For some reason, the Pareto principle angers some people. Mention the Pareto principle and someone will explain why it can’t be true, based on […]The post The world is lumpy first appeared on John D. Cook.
Another problem with A/B testing: interaction effects
The previous post looked at a paradox with A/B testing: your final result may depend heavily on the order of your tests. This post looks at another problem with A/B testing: the inability to find interaction effects. Suppose you’re debating between putting a photo of a car or a truck on your web site, and […]The post Another problem with A/B testing: interaction effects first appeared on John D. Cook.
A/B testing and a voting paradox
One problem with A/B testing is that your results may depend on the order of your tests. Suppose you’re testing three options: X, Y, and Z. Let’s say you have three market segments, equal in size, each with the following preferences. Segment 1: X > Y > Z. Segment 2: Y > Z > X. Segment […]The post A/B testing and a voting paradox first appeared on John D. Cook.
Smoothly extending arctan(k tan(t))
I wrote a while back about the function f(t) = arctan(k tan(t)). I keep running into this function. Has anybody given this function a name or studied it? The direct implementation has a discontinuity at π/2 but I needed to extend it continuously. Using the two-argument version of inverse tangent fixes this. In Python, the […]The post Smoothly extending arctan(k tan(t)) first appeared on John D. Cook.
Random illustrations of Pascal’s theorem
Pascal’s theorem begins by selecting any six distinct points on an ellipse and drawing a “hexagon.” I put hexagon in quotes because the result need not look anything like a hex nut. In this context it simply means to pick one point, connect it to some other point, and so forth, joining the points in […]The post Random illustrations of Pascal’s theorem first appeared on John D. Cook.
Finding where two quadratic curves intersect
Suppose you have two quadratic polynomials in two real variables, f(x, y) and g(x, y), and you want to know whether the two curves f(x, y) = 0 and g(x, y) = 0 intersect, and if they do, find where they intersect. David Eberly has a set of notes on solving systems of polynomial equations that […]The post Finding where two quadratic curves intersect first appeared on John D. Cook.
A more convenient squircle equation
A few years ago I wrote several posts about “squircles”, starting with this post. These are shapes satisfying where typically p = 4 or 5. The advantage of a squircle over a square with rounded edges is that the curvature varies continuously around the figure rather than jumping from a constant positive value to zero. […]The post A more convenient squircle equation first appeared on John D. Cook.
Determining a conic by points and tangents
The first post this series said that a conic section has five degrees of freedom, and that any theorem that claims to determine a conic by less than five numbers is using some additional implicit information. The second post looked at Gibbs’ method which uses three observations, and a variation on the method uses just […]The post Determining a conic by points and tangents first appeared on John D. Cook.
Four views of multisets
This post will define multisets and basic operations on multisets. We’ll view union, intersection, inclusion and sum each from four perspectives: Examples with words Example with prime factorization Using Python’s multiset module Multisets as functions Definition and examples A multiset is like a set, except each element may appear more than once. We say each […]The post Four views of multisets first appeared on John D. Cook.
Lambert’s theorem
At the start of this series we pointed out that a conic section has five degrees of freedom, and so claims to be able to determine an orbit from less than five numbers must be hiding information somewhere. That is the case with Lambert’s theorem which reportedly determines an orbit from two numbers. Lambert’s theorem […]The post Lambert’s theorem first appeared on John D. Cook.
Gibbs’ method of determining an orbit
Josiah Willard Gibbs (1839–1903) was prominent American scientist at a time when America had yet to produce many prominent scientists. I first heard of him via Gibbs phenomenon and later by attending one of the Gibbs lectures at an AMS meeting. Gibbs came up with a method of determining an orbit from three observations. As […]The post Gibbs’ method of determining an orbit first appeared on John D. Cook.
ASQ/ANSI Z1.4 sampling procedures
I mentioned the other day that the US military standard MIL-STD-105 for statistical sampling procedures lives on in the ASQ/ANSI standard Z1.4. The Department of Defense cancelled their own standard in 1995 in favor of adopting civilian standards, in particular ASQ/ANSI Z1.4. There are two main differences between military standard and its replacement. First, the […]The post ASQ/ANSI Z1.4 sampling procedures first appeared on John D. Cook.
Five points determine a conic section
This post is the first in a series looking at determining an orbit. Lambert’s theorem is often summarized by saying you can determine an orbit from two observations. This statement isn’t true without further assumptions, assumptions I plan to make explicit. A solution to the two-body problem is an orbit given by a conic section, […]The post Five points determine a conic section first appeared on John D. Cook.
Sharing data without letting it go
Suppose two companies would like to share data, but they’d also each like to retain ownership of their own data. They’d like to enable querying as if each company had given the other all its data, without actually letting go of its data. Maybe the two companies are competitors who want to collaborate for a […]The post Sharing data without letting it go first appeared on John D. Cook.
Robustness of mean range
Let’s suppose we have data that comes from a distribution that is approximately normal but has a heavier right tail, specifically a gamma distribution with shape 6. We’d like to estimate the standard deviation of the data source. If the data were normally distributed, the sample standard deviation would be the most efficient unbiased estimator. […]The post Robustness of mean range first appeared on John D. Cook.
Average digit sum
Suppose you write down a number and take the sum of its digits. In what base will this sum be the smallest on average? Let’s do a couple examples comparing base 10 and base 2. The number 2022 in base 10 has digit sum 6, but its binary equivalent 11111100110 has digit sum 8, so […]The post Average digit sum first appeared on John D. Cook.
Using mean range method to measure variability
The most common way to measure variability, at least for data coming from a normal distribution, is standard deviation. Another less common approach is to use mean range. Standard deviation is mathematically simple but operationally a little complicated. Mean range, on the other hand, is complicated to analyze mathematically but operationally very simple. ASQ/ANSI Z1.9 […]The post Using mean range method to measure variability first appeared on John D. Cook.
Elliptical orbit example: Mars Orbiter Mission
This post will look at India’s first interplanetary mission, Mars Orbiter Mission, to illustrate points in recent posts. As suggested by the logo, the probe had a very eccentric orbit of Mars with periareion 3,812 km and apoareion 80,384 km. We can derive everything else from these numbers. [1] Peri-what?! As mentioned in footnote 2 […]The post Elliptical orbit example: Mars Orbiter Mission first appeared on John D. Cook.
Military Standard 105
Military Standard 105 (MIL-STD-105) is the grand daddy of sampling acceptance standards. The standard grew out of work done at Bell Labs in the 1930s and was first published during WWII. There were five updates to the standard, the last edition being MIL-STD-105E, published in 1989. In 1995 the standard was officially cancelled when the […]The post Military Standard 105 first appeared on John D. Cook.
...10111213141516171819...