Live data from Hacker News

A surprisingly hard CS problem: sums of square roots (2018)

shlegeris.com

161–170 of 189 posts

Re: A surprisingly hard CS problem: sums of square roots (2018)

#161
I thought that any algorithms relating with real numbers (and floating point) require use of some epsilon as a measure of closeness.

In such approach some different numbers will be treated as equals, but qualified with the epsilon.

Thus it could be made practical, as long as epsilon is chosen appropriately to the application domain.

Re: A surprisingly hard CS problem: sums of square roots (2018)

#162

This is not a computer science question. It's a math challenge. We simply rely on computers to do the math faster. I challenge any math person to solve this problem and/or provide a proof. Given that their equations will ultimately be so complex they will fail. For example, just say 1/3. Easy right? 0.333333334 Wrong. It's impossible for a human or a computer to say the answer. NOT a CS issue. We can't combine random…

>Each time you reduce a number via square root you will eventually reach an infinite response and thus it's impossible to solve, let alone with a binary computer system.

This is incorrect. All the symbolic math programs in the world provide counterexamples. There is no need to deal with infinite length decimal numbers to do a lot of proving of things in mathematics, in the same manner when I prove things by hand I do not need to write out infinite length numbers.

Your mistake is assuming the only way to analyze a sqrt of a number is to write it out in infinite precision. That is not needed. For example, you can prove on a computer that sqrt(19) > sqrt(17) without having to evaluate either side as a decimal number.

For example, Mathematica (or any symbolic program), entering Sqrt[19]>Sqrt[17] returns True.

Re: A surprisingly hard CS problem: sums of square roots (2018)

#163
post #84
post #57

Earlier quoted context omitted.

Does that actually work? It seems that the degree of minimal polynomial having as root the sum of N square roots might be up to 2^N, and if you then apply the bound at https://en.wikipedia.org/wiki/Geometrical_properties_of_poly... (where n = 2^N) you get a bound on the order of at least 2^N digits (more precisely 2^N (N + D)). So it doesn't seem to lead to a proof of a subexponential number of equal digits, unless t…

Yes, the worst-case complexity is exponential in N, but the wording in the article could lead you to believe that no explicit exponential bound is known, which is false.

Do you have a reference for that claim ?

Re: A surprisingly hard CS problem: sums of square roots (2018)

#164
post #147

Earlier quoted context omitted.

> At that point you know the answer, you just have to add up the differences. What if your sum in this step is zero?

There's a known upper bound for the error on each pair delta caused by the finite number of bits. So that gives upper and lower bounds for the error on the sum of the deltas. Add enough bits to your representation to account for that error. I think that's an additional log N + 1 bits where N is the sequence length. Then if the sum comes out to zero that must be the correct answer (probably impossible unless the two s…

> Add enough bits to your representation to account for that error.

I've reviewed a few papers where authors respond with this sort of argument. It never ends in a publication. But, I really should have picked on the preceding sentence:

> Now increase k until all of the pairs are distinguished (have non-zero differences).

Do you have an estimate on the bounds, time or space, required for that? Because establishing those bounds is the "hard problem" here.

Also, what do you do about questions like sqrt(2)+sqrt(50) =? sqrt(72) where the sums have differing numbers of terms?

And, it might be worthwhile to play with an example: (55, 77, 83) and (64, 68, 82) -- depending on where you decide to truncate, the difference wobbles above, below and equal to zero, well past the point you've described where the pairwise differences are nonzero (4 bits and the sums appear to be equal). It finally stabilizes after 25 bits -- much greater than log N + 1.

Re: A surprisingly hard CS problem: sums of square roots (2018)

#165
post #134

> I’m going to update towards thinking that integers and square roots are much scarier, richer objects than I’d thought. I’ve updated to being more scared of real numbers than I used to be—they have all these sketchy properties like “almost none of them have finite descriptions”. Real numbers, and sets, and logical statements, have all started feeling to me like Cthuluesque monstrosities whose appearances are only to…

> there is something profoundly weird about [numbers] you should hear John Conway (RIP) talk about numbers - https://www.youtube.com/watch?v=1eAmxgINXrE

So I'm 40 minutes into this. For anyone reading: Conway is great, but this is basically him rambling, there really isn't any substance in this video. It's basically the Simpsons scene where grandpa is talking about onions on his belt.

Re: A surprisingly hard CS problem: sums of square roots (2018)

#166
Here is my attempt at proving that this can be done in P-time. I am using the fact that square roots can be expressed as periodic continued fractions, and that there is an upper bound on the period of these fractions which must thus be unique. Please tell me if there are any issues! I hope this holds :)

The period of the square root of n is less than k1 * (sqrt(n) log (log (log (n))) ) = Lm(n) We can find this period in polynomial time (n^3) each term is smaller than 2*sqrt(n)

Therefore, all square roots up to n are uniquely represented as part of a continued fraction expansion as a0 + 1/(a1 + 1/ (a2 + ...)) ... up to a[Lm(n)].

If we transform this nested fraction into a decimal number, any modification of this fraction will necessarily lead to a delta in the number by at least (a[Lm(n))]^-(Lm(n)), which is at most 2sqrt(n)^-(sqrt(n)

Therefore, accurately computing the square root up to the most significant digit of 2sqrt(n)^-(2sqrt(n)) will yield a result distinct from any square root up to n.

In the case of a sum of square roots, assuming that n is the largest root, accurately computing the sum up past the most significant digit of 2sqrt(n)^-Lm(n) will be sufficient to decide if a sum of square roots is larger than or smaller than another.

2sqrt(n)^-Lm(n) is reciprocally subexponential, thus the number of digits needing to be computed will grow sub-linearly with n

Therefore, the problem can be solved in polynomial time.

Re: A surprisingly hard CS problem: sums of square roots (2018)

#167
post #109
post #106

Earlier quoted context omitted.

These are fine but pretty idiosyncratic. HN doesn't have citation rules so the 'always' seems overstated. People linking papers are already going the extra mile for the benefit of others and we don't really need to berate them about how they're holding their generosity wrong.

I didn't mean to come across as berating, but rather as suggesting a better way to link. I hoped that 'request' and 'please' would set the proper tone, but am certainly open to better ways of wording it. I meant 'always' to indicate that I specifically wasn't just complaining pointlessly about the present case, but rather talking about future links; but I can see how it came across like the scolding 'always' as in a…

The PDF contains the abstract right at the top, along with full attribution, and often uses less bandwidth. In most browsers, selecting the title and first author then right-clicking "search" allows a user to find related material on the open web.

My personal preference is the PDF link.

Your request was perfectly polite, I was simply wondering what your rationale was for it.

Re: A surprisingly hard CS problem: sums of square roots (2018)

#168
post #164

Earlier quoted context omitted.

There's a known upper bound for the error on each pair delta caused by the finite number of bits. So that gives upper and lower bounds for the error on the sum of the deltas. Add enough bits to your representation to account for that error. I think that's an additional log N + 1 bits where N is the sequence length. Then if the sum comes out to zero that must be the correct answer (probably impossible unless the two s…

> Add enough bits to your representation to account for that error. I've reviewed a few papers where authors respond with this sort of argument. It never ends in a publication. But, I really should have picked on the preceding sentence: > Now increase k until all of the pairs are distinguished (have non-zero differences). Do you have an estimate on the bounds, time or space, required for that? Because establishing th…

OK, I think I understand the problem now. It's that the actual answer can be very small but non-zero. You can put error bars on your calculations but that doesn't necessarily tell you which side of zero the answer is on. In fact you would need to do the calculation with enough bits to represent the true answer which you don't know a priori. What you can do though is put an upper bound on the size of the difference between the two sums and you can make that bound as small as you want by using more bits.

Re: A surprisingly hard CS problem: sums of square roots (2018)

#169
post #142

An example of a tricky case: which is bigger, sqrt(1000000) + sqrt(1000018) + sqrt(1000036) + sqrt(1000059) + sqrt(1000083), or sqrt(1000003) + sqrt(1000011) + sqrt(1000048) + sqrt(1000050) + sqrt(1000084)? (They agree to more than 20 decimal digits of precision!)

i wonder if you can use logs to do this faster:

1. simplify the sqrt by log of each number, i.e. log(sqrt(x)) = 1/2 * log(x)

2. since sum of logs is the log of the products, i.e., log(a) + log(b) = log(ab)

you can simplify the whole expression by multiplying all the numbers, taking the log of the product once (which i presume is much faster), then multiplying by 1/2

since logs are strictly increasing, the resulting number is still going to be bigger if it originally was going to be bigger, and now you don't need to have performed all those sqrts.

Now you've reduced the problem to computing 1 log to an arbitrary precision...not sure how one does that actually...

Re: A surprisingly hard CS problem: sums of square roots (2018)

#170
post #80
post #70

Earlier quoted context omitted.

But the article presents it as an interesting pure math problem, and doesn't claim that the FP64 solution isn't good enough. I should add that the people who write state of the art "practical" TSP solvers spend a lot of time thinking about the "theoretical" complexity of it too. Turns out it's a good way to engineer those "good enough" algorithms, provide bounds etc

Sure and there are a lot of simple ways to improve the accuracy of the simple approach before you go for the pure math sledgehammer here. It's all a question of how accurate the answer needs to be. For example, It's pretty easy to come up with an FP64 error bound on the sum. And if the difference between the two sums is greater than that error bound you don't need to do anything more complicated. Where this would get…

I think people are downvoting you because you seem like you're attacking a strawman. We all agree that 1) it's an interesting math problem 2) for real-life instances, the FP64 solution is good enough.

For e.g. when you say "anything beyond that is likely unnecessary gold plating", I know you mean "exact algorithms (like the PSPACE algorithm) are unnecessary for solving real-life instances", but without context it sounds like you're saying "there is no conceivable reason people should care about the exact algorithms"

Post reply on HN