Speculative Branches
open-menu closeme
Home
Categories
Tags
About
github twitter linkedin email rss
  • Perfect Random Floating-Point Numbers

    calendar May 3, 2025 · 16 min read · Mathematical Algorithms  ·
    Share on: twitter facebook linkedin copy

    When I recently looked at the state of the art in floating point random number generation, I was surprised to see a common procedure in many programming languages and libraries that is not really a floating-point algorithm: Generate a random integer with bits chosen based on the precision of the format. Convert to …


    Read More
  • A Cryptographically Secret Santa

    calendar Dec 25, 2024 · 10 min read · Mathematical Algorithms  ·
    Share on: twitter facebook linkedin copy

    Twas about 4-6 weeks before Christmas, and all through the math department, not a creature was stirring, not even a plucky young undergrad. Cryptography professors Alice and Bob sat at the elliptically-curved conference table to plan the department's secret Santa. Mallory, the department secretary, had been given the …


    Read More
  • The Computer Architecture of AI (in 2024)

    calendar Feb 10, 2024 · 16 min read · Performance Mathematical Algorithms  ·
    Share on: twitter facebook linkedin copy

    Over the last year, as a person with a hardware background, I have heard a lot of complaints about Nvidia's dominance of the machine learning market and whether I can build chips to make the situation better. While the amount of money I would expect it to take is less than $7 trillion, hardware accelerating this wave …


    Read More
  • The Most Useful Statistical Test You Didn't Learn in School

    calendar Jul 4, 2022 · 9 min read · Performance Mathematical Algorithms  ·
    Share on: twitter facebook linkedin copy

    In performance work, you will often find many distributions that are weirdly shaped: fat-tailed distributions, distributions with a hard lower bound at a non-zero number, and distributions that are just plain odd. Particularly when you look at latency distributions, it is extremely common for the 99th percentile to be …


    Read More
  • Fixed Point Arithmetic

    calendar May 18, 2022 · 12 min read · Mathematical Algorithms Performance  ·
    Share on: twitter facebook linkedin copy

    When we think of how to represent fractional numbers in code, we reach for double and float, and almost never reach for anything else. There are several alternatives, including constructive real numbers that are used in calculators, and rational numbers. One alternative predates all of these, including floating point, …


    Read More
  • Racing the Hardware: 8-bit Division

    calendar Feb 22, 2022 · 19 min read · Mathematical Algorithms Division Performance  ·
    Share on: twitter facebook linkedin copy

    Occasionally, I like to peruse uops.info. It is a great resource for micro-optimization: benchmark every x86 instruction on every architecture, and compile the results. Every time I look at this table, there is one thing that sticks out to me: the DIV instruction. On a Coffee Lake CPU, an 8-bit DIV takes a long time: …


    Read More
  • Constant-time Fibonacci

    calendar Jan 22, 2022 · 9 min read · Mathematical Algorithms  ·
    Share on: twitter facebook linkedin copy

    This is the second part in a 2-part series on the "Fibonacci" interview problem. We are building off of a previous post, so take a look at Part I if you haven't seen it. Previously, we examined the problem and constructed a logarithmic-time solution based on computing the power of a matrix. Now we will derive a …


    Read More
  • Less-than-linear Fibonacci

    calendar Jan 14, 2022 · 6 min read · Mathematical Algorithms  ·
    Share on: twitter facebook linkedin copy

    Few interview problems are as notorious as the "Fibonacci" interview question. At first glance, it seems good: Most people know something about the problem, and there are several clever ways to achieve a linear time solution. Usually, in interviews, the linear time solution is the expected solution. However, the …


    Read More

Nima Badizadegan

Computer systems engineer, performance expert, and applied mathematician in denial. Currently at Anthropic. All views are my own, and do not reflect the opinions of my employer.
Read More

Recent Posts

  • Perfect Random Floating-Point Numbers
  • A Cryptographically Secret Santa
  • Time Programming for Lawyers and Jurors
  • Five Nine Problems
  • The Computer Architecture of AI (in 2024)
  • The Knight Capital Disaster
  • Abstraction is Expensive
  • Contemplating Randomness

Categories

NUMERICAL LIBRARIES AND FUNCTIONS 4 RANDOM 4 ENGINEERING PRACTICES 3 FUNDAMENTALS OF PERFORMANCE 3 BREAKING THE CODING INTERVIEW 2 META POSTS 2 MICRO-OPTIMIZATION 2 RANDOMNESS 2 HISTORY 1

Tags

MATHEMATICAL ALGORITHMS 8 PERFORMANCE 8 SOFTWARE ENGINEERING 7 DIVISION 1

Copyright  NIMA BADIZADEGAN. All Rights Reserved

to-top