Login
You're viewing the mastodon.coffee public feed.

Replies

  • 💬 0🔄 1⭐ 0
  • Aug 16, 2026, 5:54 AM

    @mcc you're about to hear from some math majors about the very interesting relation between the integral and the summation, it's not my place to explain this well, etc,

    💬 0🔄 0⭐ 0
  • Aug 16, 2026, 5:59 AM

    @mcc

    It's clever... I think you are essenrially using

    (n+1)² = n² + 2n + 1

    where a = n² and b = 2n + 1 ... you are starting at those values for n = 1 and then use it to compute the n = 2 squarw and then since b = 2n + const you have to increase it by 2 in each step

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 2
  • Aug 16, 2026, 8:14 AM

    @exa @philphi @mcc yep. geometric solution is the best way to get where the 2n+1 comes from; then delta 2(n+1)+1-(2n+1) = 2 and that's your b iterator.

    💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • Aug 16, 2026, 6:46 AM

    @mcc I've had a very frustrating evening that fried my brain so I'm currently futilely trying to figure out how this is and/or isn't a generalization of the fact that multiplication is "just" addition done repeatedly over and over again to begin with, so you could kind of always say that about any multiplicative sequence if you're willing to break down the steps in a certain counterintuitive way?

    💬 0🔄 0⭐ 0
  • Aug 16, 2026, 2:56 PM

    @megmac Possibly? I guess the property I'd ask if you can preserve is 'no more than a constant number of additions per step in the sequence'

    💬 0🔄 0⭐ 0
  • Aug 16, 2026, 7:11 AM

    @mcc Another similarly pleasing fact is that you can generate all the coordinates needed to plot the boundary of a circle (on a raster display) without trig, square root or even much multiplication.

    💬 1🔄 1⭐ 0
  • Aug 16, 2026, 3:01 PM

    @mal3aby @mcc I had fun using this to make a very fast geographic nearest neighbor search in mysql without any geographic indexes by making the world into pixels, and then selecting those pixels in increasing rings.

    💬 1🔄 1⭐ 0
  • 💬 0🔄 0⭐ 1
  • Aug 16, 2026, 3:59 PM

    @jmeowmeow This was on a dataset of millions, but we had people enter a location (we had a big database with centroids), and then show people near there.

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • Aug 16, 2026, 4:06 PM

    @jmeowmeow Yeah! We got along with mostly just a sorted list -- the fact that it was fast made up for the weak UI: you could just move around and it followed quickly.

    💬 0🔄 0⭐ 0
  • 💬 1🔄 0⭐ 0
  • Aug 16, 2026, 3:00 PM

    @icing yes, but this is more interesting to me because the relationship between one perfect square and the next is not a multiplication

    💬 0🔄 0⭐ 0
  • Aug 16, 2026, 12:28 PM

    @mcc I think I discovered that one in my first introduction to CS class while doing homework. It’s quite satisfying, especially to implement a bad integer square root.

    💬 0🔄 0⭐ 0
  • Aug 16, 2026, 4:59 PM

    @mcc i distinctly remember noticing this pattern back in 9th grade while staring at a poster of the perfect squares that stretched across the chalkboard!

    later, in freshman year of college, i tried using this technique in an assignment, hoping to impress my algorithms professor (himself a math PhD because CS degrees didn't exist yet when he was a student)

    he just knocked points off, because although he agreed that it may be correct, i didn't include a proof of why this non-obvious trick worked.

    💬 0🔄 0⭐ 0
  • 💬 1🔄 0⭐ 0
  • Aug 16, 2026, 5:44 PM

    @lifning Anyway, you can actually construct the proof pretty easy if you simply expand (n+1)^2-n^2

    💬 0🔄 0⭐ 0