logoalt Hacker News

0xfadedyesterday at 12:47 AM28 repliesview on HN

I once published a method for finding the closest distance between an ellipse and a point on SO: https://stackoverflow.com/questions/22959698/distance-from-g...

I consider it the most beautiful piece of code I've ever written and perhaps my one minor contribution to human knowledge. It uses a method I invented, is just a few lines, and converges in very few iterations.

People used to reach out to me all the time with uses they had found for it, it was cited in a PhD and apparently lives in some collision plugin for unity. Haven't heard from anyone in a long time.

It's also my test question for LLMs, and I've yet to see my solution regurgitated. Instead they generate some variant of Newtons method, ChatGPT 5.2 gave me an LM implementation and acknowledged that Newtons method is unstable (it is, which is why I went down the rabbit hole in the first place.)

Today I don't know where I would publish such a gem. It's not something I'd bother writing up in a paper, and SO was the obvious place were people who wanted an answer to this question would look. Now there is no central repository, instead everyone individually summons the ghosts of those passed in loneliness.


Replies

erikigyesterday at 1:10 AM

The various admonitions to publish to a personal blog, while encouraging, don't really get at the 0xfaded's request which I'd summarize as follows:

With no one asking questions these technical questions publicly, where, how and on what public platform will technical people find the problems that need solving so they can exercise their creativity for the benefit of all?

show 4 replies
sky2224yesterday at 2:49 AM

This is a perfect example of an element of Q&A forums that is being lost. Another thing that I don't think we'll see as much of anymore is interaction from developers that have extensive internal knowledge on products.

An example I can think of was when Eric Lippert, a developer on the C# compiler at the time, responded to a question about a "gotcha" in the language: https://stackoverflow.com/a/8899347/10470363

Developer interaction like that is going to be completely lost.

show 2 replies
namanyaygyesterday at 4:16 AM

I had a similar beautiful experience where an experienced programmer answered one of my elementary JavaScript typing questions when I was just starting to learn programming.

He didn't need to, but he gave the most comprehensive answer possible attacking the question from various angles.

He taught me the value of deeply understanding theoretical and historical aspects of computing to understand why some parts of programming exist the way they are. I'm still thankful.

If this was repeated today, an LLM would have given a surface level answer, or worse yet would've done the thinking for me obliviating the question in the first place.

I wrote a blog post about my experience at https://nmn.gl/blog/ai-and-learning

jvanderbotyesterday at 12:56 AM

You can write a paper, submit the arxiv, and you can also make a blog post. At any rate, I agree - SO was (is?) a wonderful place for this kind of thing.

I once had a professor mention that they knew me from SO because I posted a few underhanded tricks to prevent an EKF from "going singular" in production. That kind of community is going to be hard to replace, but SO isnt going anywhere, you can still ask a question and answer your own question for permanent, searchable archive.

show 1 reply
scirobyesterday at 10:03 AM

Has anyone tried building a modern Stack Overflow that's actually designed for AI-first developers? The core idea: question gets asked → immediately shows answers from 3 different AI models. Users get instant value. Then humans show up to verify, break it down, or add production context. But flip the reputation system: instead of reputation for answers, you get it for catching what's wrong or verifying what works. "This breaks with X" or "verified in production" becomes the valuable contribution. Keep federation in mind from day one (did:web, did:plc) so it's not another closed platform. Stack Overflow's magic was making experts feel needed. They still do—just differently now.

show 5 replies
achilleyesterday at 4:29 AM

thanks for sharing that, it was simple, neat, elegant.

this sent me down a rabbit hole -- I asked a few models to solve that same problem, then followed up with a request to optimize it so it runs more efficiently.

chatgpt & gemini's solutions were buggy, but claude solved it, and actually found a solution that is even more efficient. It only needs to compute sqrt once per iteration. It's more complex however.

                   yours  claude
  ------------------------------
  Time (ns/call)    40.5   38.3
  sqrt per iter        3      1
  Accuracy        4.8e-7 4.8e-7
Claude's trick: instead of calling sin/cos each iteration, it rotates the existing (cos,sin) pair by the small Newton step and renormalizes:

  // Rotate (c,s) by angle dt, then renormalize to unit circle
  float nc = c + dt*s, ns = s - dt*c;
  float len = sqrt(nc*nc + ns*ns);
  c = nc/len; s = ns/len;
See: https://gist.github.com/achille/d1eadf82aa54056b9ded7706e8f5...

p.s: it seems like Gemini has disabled the ability to share chats can anyone else confirm this?

show 1 reply
weatherliteyesterday at 6:54 AM

I can relate. I used to have a decent SO profile (10k+ reputation, I know this isnt crazy but it was mostly on non low hanging fruit answers...it was a grind getting there). I used to be proud of my profile and even put it in my resume like people put their Github. Now - who cares? It would make look like a dinosaur sharing that profile, and I never go to SO anymore.

OJFordyesterday at 10:43 AM

I don't disagree completely by any means, it's an interesting point, but in your SO answer you already point to your blog post explaining it in more detail, so isn't that the answer, you'd just blog about it and not bother with SO?

Then AI finding it (as opposed to already trained well enough on it, I suppose) will still point to it as did your SO answer.

zellynyesterday at 1:01 AM

Please, start a blog! Hugo + GitHub hosting makes it laughably simple. (Or pick a different stack; that’s just mine.)

Even if you’re worried it’ll be sparse and crappy, isn’t an Internet full of idiosyncratic personal blogs what we all want?

If you want help or encouragement, reach out: zellyn@ most places

show 2 replies
noduermeyesterday at 11:11 AM

That's pretty nice ;)

I once wrote this humdinger, that's still on my mostly dead personal website from 2010... one of my proudest bits of code besides my poker hand evaluator ;)

The question was, how do you generate a unique number for any two positive integers, where x!=y, such that f(x,y) = f(y,x) but the resulting combined id would not be generated by any other pair of integers. What I came up with was a way to generate a unique key from any set of positive integers which is valid no matter the order, but which doesn't key to any other set.

My idea was to take the radius of a circle that intersected the integer pair in cartesian space. That alone doesn't guarantee the circle won't intersect any other integer pairs... so I had to add to it the phase multiple of sine and cosine which is the same at those two points on the arc. That works out to:

(x^2+y^2)+(sin(atan(x/y))*cos(atan(x/y)))

And means that it doesn't matter which order you feed x and y in, it will generate a unique float for the pair. It reduces to:

x^2+y^2+( (x/y) / (x^2+y^2) )

To add another dimension, just add it to the process and key it to one of the first...

x^2+y^2+z^2+( (x/y) / (x^2+y^2) )+( (x/z) / (x^2+z^2) )

show 1 reply
Neywinyyesterday at 3:01 AM

Looks like solid code. My only gripe is the shadowing of x. I would prefer to see `for _ in range`. You do redefine it immediately so it's not the most confusing, but it could trip people up especially as it's x and not i or something.

show 1 reply
PeterStueryesterday at 9:11 AM

SO in 2013 was a different world from the SO of the 2020's. In the latter world your post would have been moderator classified as 'duplicate' of some basic textbook copy/pasted method posted by a karma grinding CS student and closed.

show 1 reply
emmelaichyesterday at 12:54 AM

You should write it up and submit it to some journal officially. Doesn't matter if it mostly duplicates your own (technically unpublished) work.

eruyesterday at 9:07 AM

I have a similar story about an interesting little advance in computing that I haven't formally published anywhere, but it's at https://cs.stackexchange.com/a/171695/50292

The question boils down to: can you simulate the bulk outcome of a sequence of priority queue operations (insert and delete-minimum) in linear time, or is O(n log n) necessary. Surprisingly, linear time is possible.

fhoyesterday at 12:15 PM

Then let me quickly say: thank you! I used that algorithm three times in different projects during my academic "career" :-)

RustyRussellyesterday at 8:36 AM

On the other hand, I once implemented something to be told later it was novel and probably the optimal solution in the space.

An AI might be more likely to find it...

eviksyesterday at 5:14 AM

> Today I don't know where I would publish such a gem.

In the same blog you published it originally, then mentioning it on whatever social media site you use? So same?

rerdaviesyesterday at 7:49 AM

Reddit is my current go-to for human-sourced info. Search for "reddit your question here". Where on reddit? Not sure. I don't post, tbh, but I do search.

Has the added benefit of NOT returning stackoverflow answers, since StackOverflow seems to have rotted out these days, and been taken over by the "rejection police".

kwakubineyyesterday at 9:43 AM

Naive question maybe but how haven’t the models been trained on your answer if it’s on SO?

show 1 reply
mightybyteyesterday at 5:59 AM

Sounds like this should live in Wikipedia somewhere on https://en.wikipedia.org/wiki/Ellipse...or maybe a related but more CS focused related page.

davchanayesterday at 1:16 AM

I too, around 2012 was too much active on so, in fact, it had that counter thing continuously xyz days most of my one liners, or snippets for php are still the highest voted answers. Even now when sometimes I google something, and an answer comes up, I realize its me who asked the same question and answered it too.

show 1 reply
baqyesterday at 10:23 AM

If you ask me your blog post is basically a paper, I’d publish to arxiv.

jmuxyesterday at 1:56 AM

This is a really method for solving that problem! I wouldn’t have thought to use the tangents but that makes perfect sense

userbinatoryesterday at 3:45 AM

That algorithm reminds me of raymarching signed distance functions.

techsystemsyesterday at 5:28 AM

Amazing work!

lbjyesterday at 7:57 AM

Really great write-up, thanks for sharing it again!

mmaazyesterday at 4:01 AM

Very cool!

qwertoxyesterday at 2:43 AM

Why did SO decide to do that to us? to not invest in ai and then, iirc, claim our contributions their ownership. i sometimes go back to answers i gave, even when answered my own questions.

show 1 reply