
Ask HN: I just discovered a new algorithm. What should I do? - 0xfaded
Hi HN,<p>For a robotics problem I have, I needed to determine the minimum distance between a point and an ellipse.<p>Existing stack overflow answers suggest using root finders to solve a quartic equation or specialised iterative methods that have instabilities.<p>https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;22959698&#x2F;distance-from-given-point-to-given-ellipse<p>One paper suggests using an initial guess on the ellipse as a root of the quartic, using the guess to simplify it to a cubic, and then solving it. The result is a fast converging stable algorithm, but solving the cubic and choosing the correct root is gross.<p>I&#x27;ve come up with a method that relies on maths that most programmers would not be familiar with, but the implementation boils down to 14 lines of python. It converges quickly (3 iterations) and is completely robust (no divergences or divide by zeros).<p>This is the first time I&#x27;ve been sitting on an algo that I genuinely believe to be novel. The robotics is a side project and work doesn&#x27;t lay claim to IP outside of work.<p>I intend to write up a blog post tomorrow, but if you were in my shoes what would you do?<p>Thanks
======
haikuginger
There're a lot of people here telling you how to "protect" your idea, and a
lot of people telling you that it's probably not novel. I just wanted to
comment and congratulate you on figuring out a method that's novel to you;
it's a legitimate discovery for you and should be celebrated even if someone
else has already found it.

------
dahart
Stack overflow has lots of great programming answers, but is by no means an
exhaustive research resource for algorithms. Have you looked through the ray
tracing literature? Good table on various geometry intersection algorithms
here:
[http://www.realtimerendering.com/intersections.html](http://www.realtimerendering.com/intersections.html)

Other search terms you might not have tried: "ray-object intersection", "ray-
ellipse intersection", "line-ellipse intersection". Also check for "ellipsoid"
algorithms, there might be something in 3d that can simplify to 2d.

Oh, also try looking through video game physics sites, tons of minimum
distance, path planning, and collision algorithms. Many physics engines are
open source, there might be some distance-to-ellipse code publicly available.
[http://www.tapirgames.com/blog/open-source-physics-
engines](http://www.tapirgames.com/blog/open-source-physics-engines)

Edit: deleted my algorithm that won't work suggestion. :P

PS: there's probably no reason not to do a blog post, there might only be
reasons not to claim it's novel, even if you don't know it yet. You might want
to write it up without claiming novelty as part of your search to figure out
if it's new. You could still publish it formally later.

------
jsnell
Write a blog post. Don't waste time doing a more exhaustive search of the
literature, but also don't go too heavy on the claims that it's totally novel.
Novelty might matter for an academic publication, but it's completely
irrelevant for a blog post. You had a problem to solve, didn't like the
solutions you could find, and came up with something better. That's what
matters, not whether it was already first published 50 years ago.

One of the more popular things I ever posted was just pointing out a an
implementation trick for a data structure that was known but not widely used.
Why would the readers care that it wasn't novel? What they cared about was a)
that they didn't already know about it, b) after reading the post they could
understand why this was a useful/interesting optimization.

~~~
locacorten
"Write a blog post. Don't waste time doing a more exhaustive search of the
literature".

No wonder the Internet has such a low SNR.

~~~
jsnell
Implying that the original poster's blog post is going to be lowering the SNR
of the Internet is a really shitty thing to say.

There are four options:

1\. This is a truly novel. The author writes a blog post.

2\. This is not novel. The author finds some prior art, and writes a blog post
about his own work but referencing the earlier work.

3\. This is not novel. The author doesn't find out, and writes a blog post.
Someone possibly responds pointing them to the relevant prior art.

4\. This is not novel. The author finds the earlier research, is discouraged,
and decides not to write a blog post.

The only bad option here is 4. So exactly what is additional research going to
achieve at this point? (There is of course a point to doing the research
before inventing your own algorithm. Or you can do it because this kind of CS
archaeology is fun. But it doesn't really have a lot of value).

------
moh_maya
[https://arxiv.org/](https://arxiv.org/)

As suggested here, perhaps consider writing up and submitting a short article
to arxiv. That ought to be enough to ensure credit. If you don't intend to
patent it (don't know where you are located & local laws), the arxiv preprint
service will give you a citable, dated & externally validated submission that
you can use. It wouldn't be peer reviewed until you submit it to an
appropriate journal, but that's a relatively short step away once you upload
the preprint to arxiv.

~~~
czep
Do you need a referral to submit to arxiv? I recall when wanting to submit a
paper there a few years ago you had to get someone who's already published to
vouch for you. Am I reading correctly?

~~~
mcguire
Yes.

[https://arxiv.org/help/submit](https://arxiv.org/help/submit)

------
rawnlq
If you care about citation count without the hassle of publishing a paper, you
should make the blog post or github repo easy to cite.

Add a blurb along the lines of "For attribution in academic contexts, please
cite this work as: (insert bibtex blob here)".

For examples, see the bottom of the posts distill.pub:
[https://distill.pub/2017/momentum/#citation](https://distill.pub/2017/momentum/#citation).
Or bottom of academic github repositories such as:
[https://github.com/sympy/sympy#citation](https://github.com/sympy/sympy#citation).

------
TAForObvReasons
You should make sure it's actually new. Study the literature carefully -- it
may have already been discovered and published. Google Patents
[https://www.google.com/?tbm=pts](https://www.google.com/?tbm=pts) is also a
good place to look. It's also worth digging into existing scientific
mathematics libraries like GSL as well as other space simulation libraries
like mantissa to see if they implemented it.

If you are just looking to put your name publicly on it, it's oftentimes good
enough just to write a blog post and make a wheel. That way you can always
point to it later and build a google presence. If you are looking to possibly
patent the algorithm, talk to a good IP attorney specializing in software
patents.

------
tootie
Find a friendly CS professor familiar with the problem domain and share your
solution. They can help determine if it's correct, if it's truly novel and if
it is, help you write a paper and get it peer reviewed.

~~~
cookiecaper
This seems like a great way to get your work appropriated by said "friendly"
professor, especially if you're coming out of the woodwork and thus don't have
a credible paper trail documenting the process of your discovery, etc.

I quite prefer approaches of private publishing that can be demonstrated to
have been publicized before said professor chooses to "help".

~~~
Someone
I may be naive, but I don't think professors would typically do that,
certainly not if you offer them to be a co-author in exchange for
professionalizing the paper (which may mean serious work, e.g. to benchmark
the algorithm against other algorithms for speed and accuracy). Even if you
don't offer that, they will have a few months to work on follow-up papers
(e.g. on I mplementing it on GPUs, in parallel, or on simple architectures)

You can also publish (e.g. by tweeting it) a hash (a few different hashes, if
you are truly paranoid) of your code before going to said professor. That
gives you some leverage against appropriation, as it would allow you to prove
you knew about the approach at a given time.

If you combine it with some context ("going to meet X to discuss
0xA43AF7F963DA003F"), that leverage gets larger. I wouldn't know whether
either would be enough, though. There likely is little jurisprudence on things
like this, it may be costly to go to court over it, and using it out of court,
e.g. by writing to any journal publishing this without your name on it, may
backfire)

------
0xfaded
Update:

Blog post has been published

[http://wet-robots.ghost.io/simple-method-for-distance-to-ell...](http://wet-
robots.ghost.io/simple-method-for-distance-to-ellipse/)

[https://news.ycombinator.com/item?id=15114026](https://news.ycombinator.com/item?id=15114026)

------
payne92
Congratulations!

I'd definitely write up a blog post. If you find the feedback confirms the
originality, you might then consider writing a short paper for arXiv. After
that, sprinkle appropriate references in StackOverflow, Wikipedia, etc. so
folks can find your work.

If you are in the US, I would not spend any time or energy trying to figure
out a patent. With the "Alice" ruling [1] in 2014, the Supreme Court has
effectively said that algorithms and business methods that are performed just
"....on a general purpose computer" are not patentable.

Also, should you get a patent, then what? Royalties to individual inventors
w/o actually developing and selling a product...it virtually never happens.

[1]
[https://en.wikipedia.org/wiki/Alice_Corp._v._CLS_Bank_Intern...](https://en.wikipedia.org/wiki/Alice_Corp._v._CLS_Bank_International)

------
PaulAJ
Getting a patent is an expensive business. Patentability of methods of
manipulating numbers is variable around the world, but in most places its not
going to work. You might have managed it in the US a few years ago, but not
now. Seriously applying for a patent is not cheap. The odds are that you will
spend a lot of money for no return.

Getting priority for something on your CV is another matter. As others have
mentioned, write up a paper and submit to arxiv.org.

Incidentally, are you aware of this:
[http://www.mathpages.com/home/kmath505/kmath505.htm](http://www.mathpages.com/home/kmath505/kmath505.htm)

The last couple of paragraphs describe a geometric construction giving an
approximation that is good enough for many purposes, and would also be the
right starting point for any iterative algorithm.

------
JacobiX
> I've come up with a method that relies on maths that most programmers would
> not be familiar with

I'm curious about the kind of math you have used for solving the problem.

~~~
qorrect
Yeah me too, I recall reading about solving this exact problem pretty
recently, bring out the goods!

------
macmac
That would very much depend on your goal. Do you just want credit, do you want
to try to monetize the algorithm, or something else entirely?

~~~
0xfaded
Good points. I'm not particularly interested in monetizing the algorithm.

I think I'd like to be able to point to it the next time I go for job
interviews. Another possible goal would be to try publish something formally
to help with an O visa (or international equvilent) should I ever need one.

Thanks

~~~
chx
Great goals, as others suggested: depending on what side of the field it falls
to, post to [https://cs.stackexchange.com/](https://cs.stackexchange.com/) or
[https://mathoverflow.net/](https://mathoverflow.net/) and ask for help
improving and whether it's original and mention you'd like to publish although
the latter is off topic there. Or you can try to email me at chx1975 gmail and
I will ask my high school classmates whether they know anyone who would be
helpful. They will. It was that sort of high school. Some became very high
level game developers some became lecturers and associate professors and so
on.

------
Const-me
I’d ask my employer for permission, then I’d write a blog post.

P.S. Have you seen this?
[https://www.geometrictools.com/GTEngine/Include/Mathematics/...](https://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistPointHyperellipsoid.h)

[https://www.geometrictools.com/Documentation/DistancePointEl...](https://www.geometrictools.com/Documentation/DistancePointEllipseEllipsoid.pdf)

~~~
ksrm
Why would you ask your employer for permission? Permission to do what, write
your own blog post?

~~~
Const-me
The OP’s question was “if you were in my shoes what would you do?”

I don’t invent stuff like that in my spare time. I do that because an employer
or client paid me for R&D.

That’s why I would ask for permission first.

------
0xfaded
OP here, I just woke up to some exceptional advice, thank you all.

I agree most with the "blog and litter stack overflow with references
approach". This accomplishes the goals of making what I have useful and
discoverable by others, and giving myself something to point to in the future.

I'll comment here and post it to HN when its ready. If it gets enough
viewership here and the advice becomes to publish a small article, I'll then
do that.

Thanks again.

------
InclinedPlane
Have you studied Numerical Analysis? There is an entire panoply of
approximation methods, I highly doubt your method is entirely novel.

------
borplk
What do you expect to be able to do with it?

I'd say just publish an academic paper on it under your name.

------
preordained
I'm so out of my depth here it isn't even funny. Just wanted to say way to
go...whether you indeed have something novel or not, thats awesome to even
have a brush with such a thing.

------
ubasu
In my experience, the method described here works very well in practice:

[http://wwwf.imperial.ac.uk/~rn/distance2ellipse.pdf](http://wwwf.imperial.ac.uk/~rn/distance2ellipse.pdf)

(this is linked to from the stackoverflow post)

Finding the closest point for an ellipsoid is more challenging in practice,
because one needs to take a different parametrization near a pole, and
sometimes conjugate gradient is necessary to get convergence.

~~~
0xfaded
Although I didn't implement this myself, the plot accompanying the answer
shows that if correctly implemented, this method is unstable in some regions
inside the ellipse.

------
gnaritas
> This is the first time I've been sitting on an algo that I genuinely believe
> to be novel.

The odds are extremely high that you're simply mistaken. While it might be
novel to programmers, it's very unlikely to be novel to mathematicians.
Research maths for prior art, or write a paper and submit to a journal for
peer review, someone will point out if it isn't novel, which it likely isn't.

------
niahmiah
Make it an open source module

------
juancn
Just write the blog post and enjoy your victory. Be as clear as possible and
explain your process.

I had fun finding how to know quickly if a rectangle and a bezier curve
intersect or not (back in 2005 I believe), it's a nice feeling to have.

------
lewisl9029
Blog post is fine, but if you want to reach as many people as possible, I'd
also post it as an answer on that Stack Overflow question. Since that's where
most developers would look first when encountering that problem (yourself
included, evidently).

------
backpropaganda
Are you sure newton's method or conjugate gradient isn't going to solve this
problem?

~~~
0xfaded
They would, however the implementation is now reduced to something you'd
happily copy and paste into a code base. Part of what's novel is how the
iterative step size is chosen. The Distance function can be very shallow in
some cases, so if one wanted to use a root finder it would probably be wise to
use an off the shelf implementation.

~~~
eps
Numerical methods is an _exceptionally_ well-researched area that saw lots of
activity back when machines were weak and Fortran was the weapon of choice.
It's more likely than not that what you discovered has been done before and/or
it's trivially derived from a more generic algorihm.

Your best bet would probably be to re-run your search (including academic
papers and not just stackoverlow, which is an inch deep) and ask around and
see what prior art will surface.

------
ta1929901
It sounds like you've done some research, but the fact you're citing stack
overflow makes me wonder where you're at in that process (nothing wrong with
stack overflow, but...)

Research the hell out of it. Google Scholar is pretty good, but if papers are
behind paywalls and you can't get them elsewhere you might have to find
library access somehow. Read original research papers and make sure it isn't
covered elsewhere.

Stack Overflow and places like that are often good starts, but people often
reinvent the wheel there, or make up things on the fly without being aware of
research papers that go into much more depth.

If you're still convinced you have something novel, write it up as an academic
paper and post it to arxiv, and then submit it to a peer-reviewed journal.
Reviewers will let you know how novel it is.

You could also post it to arxiv and/or a journal, but my guess is you'll end
up needing to cite the academic literature so you'll need to do that at some
point.

------
accordionclown
if you think you have truly found something new \-- and i must admit i was
naturally skeptical at first, but you convinced me that you'd done _some_
homework -- then don't be discouraged by the people who say "it's probably not
novel". maybe it's not, but people do discover new things every day. heck, the
odds are that you will never win a half-a-billion dollars in a lottery, but
last week a woman actually did.

------
probinso
I look forward to seeing your blog post. I would probably do the same. Very
congratulations

------
miguelrochefort
Wait, do people really get so few ideas that they feel the need to celebrate
each of them?

~~~
skellington
Many people have many ideas, very few people have novel ideas, so novel ideas
are worth being proud of because they are very few and far between. (I have no
idea if this particular idea is novel -- odds are against it though.)

------
revelation
This is satire on HN right?

~~~
miguelrochefort
The comments surely are.

------
clarry
I would mention it on IRC and then probably forget it. Maybe out the code in
some pastebin for others to see.

------
first_amendment
Patent the idea, Publish a paper, submit it to a robotics conference. Some big
company with deep pockets will buy the rights to your patent for a sum of
money that will be large to you and small for them.

~~~
daef
this is why we cant have nice things :/

