All mainstream credit card numbers obey a mathematical trick designed to catch the most common typos. It’s called the Luhn algorithm, named after IBM researcher Hans Peter Luhn, who patented it in 1960.
All mainstream credit card numbers obey a mathematical trick designed to catch the most common typos. It’s called the Luhn algorithm, named after IBM researcher Hans Peter Luhn, who patented it in 1960.
I don't know that I would call it a math trick, though I supposed to the general public it probably seems like sophisticated magic.
Hi,This is an example of one of the classic fallacies in logical reasoning, namely that if A implies B, that B therefore implies A, generally known as the fallacy of affirming the consequent. The classic example used to illustrate this fallacy is usually something like:
If it is raining, then the ground is wet.
If we limit ourselves to a world where this is always true, namely that knowing that "is raining" is True, that we can infer that "the ground is wet" is also True, then affirming the consequent would be asserting that if we know that the ground is wet, then we also know that it is raining. But this is clearly not the case, since the ground might be wet because someone just poured a bucket of water on it.
Somewhat surprisingly, because it seems so obvious when a specific absurd counterexample is used, neither the fallacy itself nor the method of disproving a universal claim by showing a single counterexample were formalized until symbolic logic was established by people like George Boole, right around 1850. Prior to that, the focus had been (for literally thousands of years) on formalizing methods of proving that something was true by deductive and inductive reasoning, and not on categorizing and recognizing invalid ways of doing so. Boole's work and its implications on logical reasoning were profound, but profound changes are seldom accepted and adopted overnight or without a fight. So, while these were widely explored topics by the beginning of the 20th century, it's not hard to imagine that quite a few established thinkers were still wedded to older schools of thought.
Hi,
It actually doesn't matter which digit is the check digit -- whichever digit it is, it is set to the value such that the checksum of the entire thing, including the check digit, meets the criteria. This is how nearly all checksum systems work.Hi,
How do we know what the "check digit" is?
Do they provide any statistical analysis?
Hello,Just for comparison:
Taylor series for sin, first 3 terms:
sin(x) = x - x^3/3! + x^5/5! …
x = arcsin(.12345678) = 0.12377256
sin0(x) = x = 0.12377256
sin1(x) = sin0(x) - x^3/3! = .12345654
sin2(x) = sin1(x) + x^5/5! = .12345678
Edited to clarify the three successive approximations.
Yes, this is why range reduction is needed in computing many functions.For small numbers like 0.1 the Taylor series converges somewhat fast, but as x gets larger, we need more and more terms to get fast convergence. If we look at the error, it actually increases very fast as we get close to 1.
Hi again,Yes, this is why range reduction is needed in computing many functions.
Take a look at one cycle of sin. Divide it into 8 equal regions of π/4. On each of the 8 regions, the sin is equivalent to either a sin or cosine of an adjusted argument in the range of 0 to π/4, either negated or not.
An optimized polynomial with, I think, 5 terms, will give you 8 digits. The two polynomials (sin and cos) over 0 to π/4 can therefore give you the sin and cos of any angle.
There are more complex methods to reduce the range further and use even a smaller numbers of terms, but the range reduction then takes enough compute to erase the advantage.
I have written math libraries that, in software, rivaled the old original 8087 coprocessor in performance (when using the 8087 for the basic operations.)
Years ago , I wrote a 3D API, it was for a low speed 68008 CPU. To do trig, I simply populated an array, 180 slots, giving 0.5 degree resolution. Runtime calculations were therefore lighting fast (but I did have to build the table at startup).For starters, sin(-x) = - sin(x)
So any sin can be the sin of a positive number possibly negated. That is the first reduction of range.
Next, As you know, sin(x) is periodic with a period of 2π. So the next step in reducing the argument is to write the argument in the form
x = n * 2π + r
Now sin(x) = sin(r)
where n is an integer and
0 ≤ r ≤ 2π
Next we divide the 2π range into 8 equal parts of width 2π/8 or π/4. Draw this and it is easy to see the rest of it graphically.
Based on sin(x) = cos(x-π/4), and the first identity above, we can see that sin(x) in each of these regions is equal to either sin or cos of an equivalent angle between 0 and π/4.
So every sin(x) is equal to either a sin or cos of an angle x’ such that
0 ≤ x’ ≤ π/4
You can look up the book “Approximation of Functions” by Rice et al, 1964. Rice was my numerical analysis prof in grad school, and would have been my thesis advisor had I continued to a PhD in that specialty.
As I showed before, the Taylor series needs only 5 terms to get 8 digits over that range.
But you can do even better. Chebyshev polynomials can be used to optimize the coefficients for even smaller error. But that is beyond the scope of this post (not to mention that I would have to look it up.)
Hello again,For starters, sin(-x) = - sin(x)
So any sin can be the sin of a positive number possibly negated. That is the first reduction of range.
Next, As you know, sin(x) is periodic with a period of 2π. So the next step in reducing the argument is to write the argument in the form
x = n * 2π + r
Now sin(x) = sin(r)
where n is an integer and
0 ≤ r ≤ 2π
Next we divide the 2π range into 8 equal parts of width 2π/8 or π/4. Draw this and it is easy to see the rest of it graphically.
Based on sin(x) = cos(x-π/4), and the first identity above, we can see that sin(x) in each of these regions is equal to either sin or cos of an equivalent angle between 0 and π/4.
So every sin(x) is equal to either a sin or cos of an angle x’ such that
0 ≤ x’ ≤ π/4
You can look up the book “Approximation of Functions” by Rice et al, 1964. Rice was my numerical analysis prof in grad school, and would have been my thesis advisor had I continued to a PhD in that specialty.
As I showed before, the Taylor series needs only 5 terms to get 8 digits over that range.
But you can do even better. Chebyshev polynomials can be used to optimize the coefficients for even smaller error. But that is beyond the scope of this post (not to mention that I would have to look it up.)
Maybe you already mentioned this previously, but I couldn't spot it quickly. What was the application where 800 digits wasn't enough?Hello again,
That sounds interesting, but 8 digits means almost nothing to me. Even 80 digits or 800 digits is still not enough.
Here's a result from my simple calculator I did years back:
0.7071067811865475244008443621048490392848359376884740365883398689409498
and that is still far too short.
The question of how you know how many digits are truly significant takes on added emphasis given your example.Hello again,
That sounds interesting, but 8 digits means almost nothing to me. Even 80 digits or 800 digits is still not enough.
Here's a result from my simple calculator I did years back:
0.7071067811865475244008443621048490392848359376884740365883398689409498
and that is still far too short.
0.7071067811865475244008443621048490392848359376884740365883398689 409498
0.7071067811865475244008443621048490392848359376884740365883398689 953662392310535194251937671638207864