CINXE.COM

Password Math

<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type='text/xsl' href='blogformat.xsl' version='1.0'?> <!-- (c) 2020 by Charles Petzold (www.charlespetzold.com) --> <blog> <item> <title>Password Math</title> <permalink>2025/02/Password-Math.html</permalink> <comments /> <dateline>February 8, 2025<br />New York, N.Y.</dateline> <content> <p> A friend from my <i>PC Magazine</i> days recently posted on Facebook a little mathematics anomaly that he encountered while trying to figure out the number of possible passwords under certain conditions. He began with the stipulation that a four-character password had to be constructed from characters from each of four groups: 26 uppercase letters (which I’ll abbreviate as U), 26 lowercase letters (L), 10 numeric digits (N), and 18 special characters (S), for a total of 80. </p> </content> <datetime>Sat, 08 Feb 2025 15:50:01 GMT</datetime> </item> <item> <title>Reading Jack Smith’s “Final Report” </title> <permalink>2025/01/Reading-Jack-Smiths-Final-Report.html</permalink> <comments /> <dateline>Inauguration Day, 2025<br />New York, NY</dateline> <content> <p> This is a good-news-bad-news kind of day. </p> </content> <datetime>Mon, 20 Jan 2025 17:00:00 GMT</datetime> </item> <item> <title>A Conversation on the DEX Show</title> <permalink>2025/01/A-Conversation-on-the-DEX-Show.html</permalink> <comments /> <dateline>January 18, 2025<br />New York, N.Y.</dateline> <content> <p> I recently had a delightful remote chat with Tom McGrath of the DEX Show podcast (a presentation of the <a href="https://nexthink.com/">nexthink</a> software company) about the 2nd edition of my book <i>Code: The Hidden Language of Computer Hardware and Software</i> and some other issues. Here it is: </p> </content> <datetime>Sun, 19 Jan 2025 19:11:49 GMT</datetime> </item> <item> <title>Very Wrong Math</title> <permalink>2025/01/Very-Wrong-Math.html</permalink> <comments /> <dateline>January 10, 2025<br />New York, N.Y.</dateline> <content> <p> The difference between misinformation and disinformation is the difference between ignorance and malice. Trolling is somewhat different, incorporating an element of provocation and narcissism. But what the hell is this? </p> </content> <datetime>Fri, 10 Jan 2025 18:36:04 GMT</datetime> </item> <item> <title>2025 Project: “The Lost Art of Logarithms”</title> <permalink>2025/01/2025-Project-The-Lost-Art-of-Logarithms.html</permalink> <comments /> <dateline>January 1, 2025<br />Roscoe, N.Y.</dateline> <content> <p> I don’t make New Year’s resolutions, but I do have New Year’s projects, and for 2025 I hope to spend as much time as possible working on my book <i>The Lost Art of Logarithms</i>. </p> </content> <datetime>Wed, 01 Jan 2025 12:00:00 GMT</datetime> </item> <item> <title>The Best Decade in Music</title> <permalink>2024/12/The-Best-Decade-in-Music.html</permalink> <comments /> <dateline>December 14, 2024<br />New York, N.Y.</dateline> <content> <p> Like many people who turned 11 years old in 1964, the first record album I bought “on my own” — in other words by pleading “Mom, can you get this album for me?” — was <i>Meet the Beatles!</i>, their first release in the United States. But so what? I have about as much inclination to listen to that album now as to watch episodes of <i>My Favorite Martian</i>, which was my favorite television series at the time. </p> </content> <datetime>Sat, 14 Dec 2024 18:00:00 GMT</datetime> </item> <item> <title>Dice Music from 1759</title> <permalink>2024/08/Dice-Music-from-1759.html</permalink> <comments /> <dateline>September 31, 2024<br />Roscoe, N.Y.</dateline> <content> <p> In the latter half of the 18th century, several composers experimented with composing music using dice. The most famous example was published in Berlin in 1793 and attributed to Mozart </p> </content> <datetime>Wed, 30 Oct 2024 19:36:26 GMT</datetime> </item> <item> <title>Stop Fascism: Vote Blue</title> <permalink>2024/10/Stop-Fascism-Vote-Blue.html</permalink> <comments /> <dateline>October 20, 2024<br />New York, N.Y.</dateline> <content> <p> It might seem silly for a retired technical writer and obscure blogger to endorse a Presidential candidate. I am not vain enough to believe that my prestige (such as it is) has the power to influence people’s electoral choices. But I believe this election to be too important for anyone to remain silent. Silence is not an option. Silence equals complicity. </p> </content> <datetime>Sun, 20 Oct 2024 16:00:00 GMT</datetime> </item> <item> <title>Rudimentary 3D on the 2D HTML Canvas</title> <permalink>2024/09/Rudimentary-3D-on-the-2D-HTML-Canvas.html</permalink> <comments /> <dateline>September 29, 2024<br />New York, N.Y.</dateline> <content>I've been working on a graphical web project that requires an interactive roll of a pair of dice. Dice are cubes and would be most convincingly rendered with 3D graphics. But because these dice are only a tiny part of this project, I was reluctant to call out the big guns. I didn't want to wrestle with the low-level [WebGL](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API) to do 3D graphics or even a friendlier WebGL wrapper such as [three.js](https://threejs.org/). Moreover, most of the project involving the dice uses conventional HTML5 Canvas graphics, and you can't mix those 2D graphics and WebGL on the same canvas element. (WebGL supports 2D graphics as well as 3D but it's a whole different animal.) For these reasons, I felt I could simulate 3D dice with much simpler 2D graphics and a little math. !JavaScript CubeWireFrame.js !JavaScript DieDemo.js !JavaScript Vector3.js !JavaScript PatternTransform.js !JavaScript Die3D.js !JavaScript MeshGeneratorBase.js !JavaScript FlatSurfaceMeshBase.js !JavaScript PolyhedronMeshBase.js !JavaScript DodecahedronMesh.js !JavaScript Color.js !JavaScript DodecahedronDemo.js !JavaScript SphereMesh.js !JavaScript BadSphereDemo.js !JavaScript WebGLTriangle.js !JavaScript LinearGradientTriangle.js !JavaScript CylindricalMeshBase.js !JavaScript CylinderMesh.js !JavaScript CylinderDemo.js !JavaScript SphereDemo.js !JavaScript Demos3D.js !CSS 3Don2D.css I started with a wireframe display of a cube: <div class="canvas-container" style="margin: 0 160px"> <canvas id="idCubeCanvas" width="400" height="400"></canvas> </div> <div width="100%"> <input id="idCubeSliderX" type="range" class="slider" value="15" min="-180" max="180" step="1"></input> <p id="idCubeTextX" class="ui-text slider-text slider-text-X slider-text-degrees">15</p></content> <datetime>Sun, 29 Sep 2024 15:00:00 GMT</datetime> </item> <item> <title>“Fantasy on a Fugue” (Revisited)</title> <permalink>2024/08/Fantasy-on-a-Fugue-Revisited.html</permalink> <comments /> <dateline>August 2, 2024<br />Roscoe, N.Y.</dateline> <content>This has been on my to-do list for 40 years. Around 1980, while immersed in the music of Philip Glass and Steve Reich, I became intrigued by the idea of [process music](https://en.wikipedia.org/wiki/Process_music) and conceived of a composition based on the Fugue in C minor from Book 1 of J. S. Bach's *Well-Tempered Clavier*, a piece I had first heard (along with its accompanying Prelude) on Wendy Carlos's groundbreaking album *Switched-On Bach* in 1969 when I was 16 years old. !JavaScript BachFugue.json.js !JavaScript FMToneSupply.js !JavaScript CompositionPlayer.js !JavaScript MusicalSymbols.js !JavaScript ScoreDisplay.js !JavaScript FantasyOnAFugue.js !JavaScript new FantasyOnAFugue(); !CSS FantasyOnAFugue.css !CSS https://fonts.googleapis.com/css?family=Quintessential The composition I dreamed up can be described in one sentence: > Bach's Fugue in C Minor (BWV 847) is played from beginning to end in one-measure windows that advance by a sixteenth note after a certain number of repetitions. In effect the fugue is played in slow motion, but I figured that the tempo would be set so fast that the listener would experience a blistering flurry of notes, which seemed kind of cool to me. I knew that this might be played by a human being, but certainly not me, whose uncoordinated fingers can't even manage Bach's Two-Part Inventions. Fortunately, at the time that I concocted this composition, I was building a [microprocessor-controlled digital electronic music synthesizer](https://www.charlespetzold.com/etc/AdventuresInElectronicMusic/#digitalsynth) that I figured could play this composition for me. Indeed, the prospect of transforming a Bach fugue into Philip Glassian trippiness was a major impetus to finishing the synthesizer and programming it to play music. And so I did. In May 1982, I was able to play the composition from my synthesizer and record it. By this time I was calling it *Fantasy on a Fugue*, despite the fact that it didn't at all fit the notion of a musical fantasy. Oh well: too late now to change the name now. But I was never quite happy with it. I thought that such a brilliant conception deserved a better realization. Over the decades, I've wanted to revisit *Fantasy on a Fugue*, and I began to think it might be made more interactive, and perhaps more visual. By the late 1990's Windows had acquired sound-generation facilities that I explored with much enthusiasm — the classic 5th edition of *Programming Windows* published in 1999 has a 130-page chapter devoted to sound and music — but I never had enough free time to implement a new version of this composition. Ten years later, I was playing around with Silverlight, which had the potential of allowing me to put a new version of *Fantasy on a Fugue* on a website so that the entire world could experience it (or perhaps charge my apartment with torches and pitchforks). I explored Silverlight sound generation sufficiently to write a little [sequencer](https://www.charlespetzold.com/blog/2009/07/Simple-Electronic-Music-Sequencer-for-Silverlight.html), but then I got into Windows Phone and Windows 8, and Silverlight slipped away before I could get much deeper. Recently I've been exploring the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API), which I believe has a somewhat better chance of surviving longer than Silverlight. By combining Web Audio with the graphics of the [HTML5 Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API), I could do things that were unfathomable when I conceived this composition over 40 years ago. So here it is, enhanced with a synchronized visual display of the score and a bunch of sliders for interactivity: <p class="composition-title">Fantasy on a Fugue</p></content> <datetime>Fri, 02 Aug 2024 12:00:00 GMT</datetime> </item> <item> <title>That Bullshit Income-Inequality Meme</title> <permalink>2024/06/That-Bullshit-Income-Inequality-Meme.html</permalink> <comments /> <dateline>June 17, 2024<br />New York, N.Y.</dateline> <content> <p> Memes can be fun and sometimes even informative, but when memes contain numbers — and particularly numbers without a source — memes can be deceptive and just plain wrong. For example, here’s a meme that’s been floating around that purports to illustrate income inequality in the United States: </p> </content> <datetime>Mon, 17 Jun 2024 16:00:00 GMT</datetime> </item> <item> <title>Netflix Cancels Bach, Mozart, Beethoven</title> <permalink>2024/05/Netflix-Cancels-Bach-Mozart-Beethoven.html</permalink> <comments /> <dateline>May 28, 2024<br />Roscoe, N.Y.</dateline> <content> <p> I’m a fan of <i>Bridgerton</i> (Team Penelope, if you care), the feel-good Netflix series portraying a fantastical harmoniously multiracial Regency England, and renowned for its steamy sex scenes, the marvelous Shonda Rhimes touch, and clever quasi-“classical” arrangements of pop songs. These arrangements avoid the anachronistic incongruity of 19th century sets and costumes accompanied by the disconcerting sounds of drum kits, electric guitars, synthesizers, and pitch correction. </p> </content> <datetime>Tue, 28 May 2024 14:00:00 GMT</datetime> </item> <item> <title>Reading About the Dreyfus Affair</title> <permalink>2024/05/Reading-about-the-Dreyfus-Affair.html</permalink> <comments /> <dateline>May 27, 2024<br />Roscoe, N.Y.</dateline> <content> <p> One of my 2024 projects is to read Marcel Proust’s <i>In Search of Lost Time</i> at the rate of about 10 pages a day, and so far it’s been successful: I’m currently heading towards the end of the 3rd volume, <i>The Guermantes Way</i>. During a long dinner party in this novel, seemingly everyone has taken sides in the Dreyfus Affair. This is an episode in French history centered around a wrongful arrest and conviction for an act of espionage, but characterized by a shockingly overt manifestation of antisemitism. </p> </content> <datetime>Mon, 27 May 2024 17:59:53 GMT</datetime> </item> <item> <title>Roget’s Enhancement to the Slide Rule</title> <permalink>2024/05/Rogets-Enhancement-to-the-Slide-Rule.html</permalink> <comments /> <dateline></dateline> <content> <p> content before </p> </content> <datetime>Mon, 13 May 2024 15:44:26 GMT</datetime> </item> <item> <title>An Interactive Roget’s Categorical Thesaurus</title> <permalink>2024/04/An-Interactive-Rogets-Categorical-Thesaurus.html</permalink> <comments /> <dateline></dateline> <content> <p> For over 170 years, writers have been using a thesaurus to turn their dull, boring, insipid, lifeless, flat, uninspiring prose into brilliant, dazzling, vivid, resplendent writing that sparkles with radiant wit and lyricism. Although uninhibited, indiscriminate, reckless, or promiscuous use of a thesaurus can have ostentatious, flamboyant, and lurid results, a thesaurus is of invaluable aid for finding the perfect words to complete crafting a sentence that delights rather than disappoints. </p> </content> <datetime>Tue, 30 Apr 2024 12:00:00 GMT</datetime> </item> <item> <title>Interactive Graphical Arithmetic</title> <permalink>2024/04/Interactive-Graphical-Arithmetic.html</permalink> <comments /> <dateline>April 8, 2024<br />New York, N.Y.</dateline> <content>When called upon to perform basic arithmetic these days, most of us grab the nearest device with a calculator app. On the rare occasions when the power is out and the batteries have run down, we might need to resort to doing the calculation by hand. In either case, we’re performing a *digital* calculation, meaning that we’re manipulating discrete *digits* in an algorithmic procedure. !JavaScript Canvas.js !JavaScript Compass.js !JavaScript Scales.js !JavaScript LipkaArithmetic.js !JavaScript LogScaleConstruct.js !JavaScript CompassArithmetic.js !JavaScript new LipkaAdder("idCanvasLipkaAdder"); !JavaScript new LipkaMultiplier("idCanvasLipkaMultiplier"); !JavaScript new DistanceConstruct("idCanvasDistanceConstruct"); !JavaScript new PowerConstruct("idCanvasPowerConstruct"); !JavaScript new CompassAdder("idCanvasCompassAdder"); !JavaScript new CompassMultiplier("idCanvasCompassMultiplier"); !JavaScript new LipkaCombo("idCanvasLipkaCombo"); !CSS AddlBlogStyles.css But arithmetic can also be performed as an *analog* process. For instance, values can be represented by distances on a ruler or scale. That ruler might have numbers on it and discrete tick marks between the numbers, but generally a position on a ruler involves a linear interpolation between two tick marks. Here’s an interactive graphic that lets you perform an analog addition of two three-digit numbers: <div class="canvas-container" style="margin: 0 -170px"> <canvas id="idCanvasLipkaAdder" width="1060" height="530"></canvas> </div> The scales on the top and bottom go from 0 through 10. Use the mouse or touch to move the cyan circles on the top and bottom scales to select two numbers to add. A line connects the two selected values and passes through the center scale, which indicates the sum. Notice that the center scale goes up to 20 to accomodate all the possible additions. To subtract, set the second number (the "subtrahend”) on the top scale and then the first number (the "minuend”) on the center scale. The bottom scale shows the difference, but only if it's a positive values. This thing qualifies as an analog calculator because in real life, these scales might be drawn on a sheet of paper. You’d connect two numbers using a straight edge but some visual interpolation would be involved, and eyeballs are analog devices. I’ve provided a “cheat” at the bottom showing the values as if this were a digital calculator but you really shouldn't be relying on those. Also, those numbers are subject to rounding errors! Because these scales are 1000 pixels wide, the precision is limited to three digits, but you aren’t limited to adding values between 0 and 10. You can add larger or smaller numbers if they’re of the same magnitude. For example, you can add 256 and 768 by adding 2.56 and 7.68 and then adjusting the result by moving the decimal two places. But it gets quite awkward if the numbers are not of the same magnitude, for example, if you wanted to add 256 and 7.68. Because of that limitation — and because it’s probably easier to manually add three-digit numbers rather than manipulating a straightedge on some rulers drawn on a piece of paper — ultimately you'll probably conclude that this little analog adder is cute but undeniably lame. But what about multiplication? Multiplying a pair of three-digit numbers by hand is a rather more complicated process than adding them. Can you construct something similar but for multiplication rather than addition? The first change would be to extend the middle scale to 100 rather than 20 for the maximum multiplication of 10 by 10. But even then, some other changes would be required, and if you don't know the "trick" involved, you might spend much time on this problem. So what's the trick? If you alter the scales so that they’re stretched out at the beginning and progressively scrunched up at the end, and you do this is in precisely "the right way," you get something that works: <div class="canvas-container" style="margin: 0 -170px"> <canvas id="idCanvasLipkaMultiplier" width="1060" height="530"></canvas> </div> Notice that the top and bottom scales go from 1 to 10, but the center scale goes from 1 through 100, and moreover, the part of that center scale from 1 to 10 is the same width as the part from 10 through 100. You can use this to multiply numbers of any magnitude just so long as you keep track of the decimal places. For example, you might want to multiply 65,500 by 0.235. Set 6.54 on the top scale and 2.35 on the bottom. The result is 15.39. But one of the numbers was adjusted by moving the decimal point 4 places left, and the other by 1 place right. Subtract 1 from 4 to get 3 and move the decimal point of the result 3 places right for 15,390, which is pretty close to what you'd get if you multiplied using a digital calculator. Now obviously the numbers on these multiplication scales are stretched out and scrunched together in a very particular way. These are *logarithmic* scales, and I’ll show you shortly how they can be constructed. I’ve recently been working on a book about logarithms — what the hell they are, where they came from, why they’re still important, and all that stuff. I intend for that book to contains lots of interactive graphics like these. Here’s a brief overview of how logarithms came to be: In 1615, Scottish polymath John Napier published a book entitled *Mirifici Logarithmorum Canonis Descriptio* that described a technique that made multiplying numbers *almost* as easy as adding them. For people who needed to do a lot of heavy mathematics (astronomers and navigators, particularly), this was a revelation. Napier's technique involved pages and pages of tables. You’d look up the two numbers you needed to multiply in these tables and get magic numbers that Napier called “logarithms,” a word he invented meaning “ratio numbers.” You’d add the two logarithms to get another logarithm that you’d look up in the table to get the product. It was messy, but it was easier than multiplying numbers by hand. For over 350 years, logarithms were essential in facilitating multiplication. Then pocket calculators became available in the 1970s and logarithms were mostly forgotten except by engineers and scientists who still need to use them. Although John Napier conceived his logarithms in a very peculiar manner, today we understand logarithms as the inverse function of exponentiation. In short, if <math><mi>y</mi><mo>=</mo><msup><mn>10</mn><mi>x</mi></msup></math> that is, if *y* equals 10 to the *x* power (if *y* equals 10 multiplied by itself *x* times), then the logarithm of *y* equals *x*, or: <math><mi>x</mi><mo>=</mo><mo>log</mo><mo>(</mo><mi>y</mi><mo>)</mo></math> More specifically, that is called a base-10 logarithm because 10 to the *x* power equals *y*. For example, 10 to the 3rd power is 1,000 so the base-10 logarithm of 1,000 is 3. Ten to the 6th power is a million so the logarithm of a million is 6. But logarithms also work with fractional powers. You can combine those two expressions with each other in two different ways to get useful identities. If you substitute *y* in the second expression with its equivalent from the first expression, you get: <math><mi>x</mi><mo>=</mo><mo>log</mo><mo>(</mo><msup><mn>10</mn><mi>x</mi></msup><mo>)</mo></math> The logarithm of 10 to the 3rd power equals 3. You can also combine the first two expressions like this: <math><mi>y</mi><mo>=</mo><msup><mn>10</mn><mrow><mo>log</mo><mo>(</mo><mi>y</mi><mo>)</mo></mrow></msup></math> That looks odd but it works. If *y* is 1000 then the logarithm of *y* is 3, and 10 to the 3rd power indeed equals 1000. If you multiply two powers of 10, you can add the exponents: <math><msup><mn>10</mn><mi>A</mi></msup><mo>×</mo><msup><mn>10</mn><mi>B</mi></msup><mo>=</mo><msup><mn>10</mn><mrow><mi>A</mi><mo>+</mo><mi>B</mi></msup></math> You can convince yourself of this with simple numbers for *A* and *B*. For example, if *A* is 3 and *B* is 5, then, 1,000 times 100,000 equals 100,000,000, which is 10 to the 8th power. Similarly, it can be shown that the logarithm of a multiplication is the addition of two logarithms: <math><mo>log</mo><mo>(</mo><mi>A</mi><mo>×</mo><mi>B</mi><mo>)</mo><mo>=</mo><mo>log</mo><mo>(</mo><mi>A</mi><mo>)</mo><mo>+</mo><mo>log</mo><mo>(</mo><mi>B</mi><mo>)</mo></math> If *A* equals 1,000 and *B* equals 100,000 then the logarithm of 100,000,000 equals 8, which is the logarithm of 1,000 plus the logarithm of 100,000. This reveals the basic insight: <p class="center"><b>Multiplication is the addition of logarithms!</b></p></content> <datetime>Mon, 08 Apr 2024 16:00:00 GMT</datetime> </item> <item> <title>The Wrath of God and the Ethics of Belief</title> <permalink>2024/02/The-Wrath-of-God-and-the-Ethics-of-Belief.html</permalink> <comments /> <dateline>February 21, 2024<br />New York, N.Y.</dateline> <content> <p> Some crazy stuff pops up in the news these days, but I truly wasn’t ready for the Chief Justice of a state Supreme Court to invoke the “wrath of a holy God” in a court ruling. </p> </content> <datetime>Wed, 21 Feb 2024 17:00:00 GMT</datetime> </item> </blog>

Pages: 1 2 3 4 5 6 7 8 9 10