Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

OK, the code

```
f[a_] := Piecewise[{{(Abs[a])^(-1), a != 0}, {0, a == 0}}]
g[b_] := Piecewise[{{(Abs[b])^(-1), b != 0}, {0, b == 0}}]
h[c_] := Piecewise[{{(Abs[c])^(-1), c != 0}, {0, c == 0}}]
Sum[f[a]*g[b]*h[c] Boole[a + b + c == 0], {a, -100, 100}, {b, -100,
100}, {c, -100, 100}]
```

yields 13.6862.

I'm going to try and see what happens after raising the dimension to d = 2.

```
f[a_] := Piecewise[{{(Abs[a])^(-1), a != 0}, {0, a == 0}}]
g[b_] := Piecewise[{{(Abs[b])^(-1), b != 0}, {0, b == 0}}]
h[c_] := Piecewise[{{(Abs[c])^(-1), c != 0}, {0, c == 0}}]
Sum[f[a]*g[b]*h[c] Boole[a + b + c == 0], {a, -150, 150}, {b, -150,
150}, {c, -150, 150}]
```

yields 13.8993.

*Last edited by zetafunc (2016-11-20 08:18:22)*

**LearnMathsFree: Videos on various topics.New: Integration Problem | Adding FractionsPopular: Continued Fractions | Metric Spaces | Duality**

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

Hi;

Am I correct in assuming that you only want the terms of f(a)g(b)h(c) when a + b + c = 0?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

Yes.

**LearnMathsFree: Videos on various topics.New: Integration Problem | Adding FractionsPopular: Continued Fractions | Metric Spaces | Duality**

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

The code looks fine now.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

I am not sure how to extend this to 2 dimensions without getting something overly complicated.

**LearnMathsFree: Videos on various topics.New: Integration Problem | Adding FractionsPopular: Continued Fractions | Metric Spaces | Duality**

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

How do you raise the dimension to 2?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

We would have to replace the norms Abs[a] with the equivalent norm in 2 dimensions, which is going to look like Sqrt[a^2 + b^2] instead, and we will have to replace the conditions with a^2 + b^2 != 0, etc. and eventually sum over 6 variables. I'm trying even with just (-2,2) as the ranges and that is taking a long time.

*Last edited by zetafunc (2016-11-20 08:31:02)*

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

If d = 1 converges the code in post #26 is not convincing.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

Why do you say that?

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

Based on the numbers 13.8993 and 13.6862 we can not even be sure that is converging. The harmonic series increases very slowly and does not converge.

If the sum in post #26 is converging it is doing it very slowly.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

I will try with bigger numbers and maybe leave it on overnight, and see what happens.

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

You can be sure that it will much more difficult to do with d = 2.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

I think analytic methods are more appropriate in that case, and that Mathematica should be used to establish confidence in the d = 1 case (if it diverges for d = 1, then certainly it will diverge for d = 2).

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

Okay, good point.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

I should also mention that convergence for d = 2 would have interesting implications for the Gauss circle problem. More precisely it would suggest something about the maximum value of the remainder. But let us not get ahead of ourselves (as I have learned not to do in the past on working on this problem).

*Last edited by zetafunc (2016-11-20 09:23:59)*

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

Run it off tonight for 200, 250, 300...that way I can use a sequence accelerator on it. Although, they say that it should be done in powers of two, 64,128, 256, 512 but I am not exactly sure why.

See you later, I am going to cook something to eat.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

200 seems to be taking a really long time. That would be interesting -- maybe I will try to use powers of 2 instead if it is necessary.

OK, see you later.

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

```
f[a_] := Piecewise[{{(Abs[a])^(-1), a != 0}, {0, a == 0}}]
g[b_] := Piecewise[{{(Abs[b])^(-1), b != 0}, {0, b == 0}}]
h[c_] := Piecewise[{{(Abs[c])^(-1), c != 0}, {0, c == 0}}]
Sum[f[a]*g[b]*h[c] Boole[a + b + c == 0], {a, -200, 200}, {b, -200,
200}, {c, -200, 200}]
```

has given 14.0131, after about 40 minutes.

EDIT: Also:

```
f[a_] := Piecewise[{{(Abs[a])^(-1), a != 0}, {0, a == 0}}]
g[b_] := Piecewise[{{(Abs[b])^(-1), b != 0}, {0, b == 0}}]
h[c_] := Piecewise[{{(Abs[c])^(-1), c != 0}, {0, c == 0}}]
Sum[f[a]*g[b]*h[c] Boole[a + b + c == 0], {a, -250, 250}, {b, -250,
250}, {c, -250, 250}]
```

has given 14.0846 after a little over 21 minutes. (I don't know why this was so much faster.)

Finally,

```
f[a_] := Piecewise[{{(Abs[a])^(-1), a != 0}, {0, a == 0}}]
g[b_] := Piecewise[{{(Abs[b])^(-1), b != 0}, {0, b == 0}}]
h[c_] := Piecewise[{{(Abs[c])^(-1), c != 0}, {0, c == 0}}]
Sum[f[a]*g[b]*h[c] Boole[a + b + c == 0], {a, -300, 300}, {b, -300,
300}, {c, -300, 300}]
```

yields 14.1339 after 39 minutes.

*Last edited by zetafunc (2016-11-20 11:18:53)*

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

Hi;

You can use the AbsoluteTiming command to do the timing automatically. I am working on a speedup to the problem.

Using the speedup I was able to do to 1000 in 2 minutes and 15 seconds. I got 14.3229. Still not seeing the expected convergence.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

How did you speed it up?

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

I am glad I found this idea for you and would love to tell you, but first you have to listen to der spiel.

[Begin der spiel]

Do you know I talk to supposedly intelligent people on forums everyday and I have trouble convincing them not the teakettle principle, and not experimental mathematics. They generally just scoff and smirk when I mention those things to them. What does a bumpkin know they say? Nope, the one obvious fact to me and not obvious to them, is this simple relationship:

Mathematics + Programming > Mathematics

I have tried to convince them by subtracting Mathematics from both sides but they still do not get it. Is there more? You bet!

Mathematics + Programming > Programming.

Enough with der spiel for today.

[End der spiel]

Your problem just wants the sum of all tuples between -n and n that do not have a zero in them and sum to 0. Then take those tuples and invert and multiply each element in the tuple.

If we find those tuples first we can reduce the number we have to sum. So in a -300 to 300 example instead of 601^3 = 217081801 tuples, we only work with 3 (300^2 - 300) = 269100 tuples. This is more than a marginal improvement.

This code here will sum all the tuples that we need from -1000 to 1000 in about 135 seconds on my machine.

```
n =1000;
AbsoluteTiming[
Total@(Times @@@
Abs[{a, b, c}^-1 /.
FindInstance[{a + b + c == 0, a != 0, b != 0,
c != 0, -n <= a <= n, -n <= b <= n, -n <= c <= n}, {a, b, c},
Integers, 3 n^2 - 3 n]]) // N]
```

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

That does look much more efficient than what we were working with before. I'm not familiar with some of the things in your code but I'd like to get my hands dirty with it.

However, I ran that code a couple of times on Mathematica 10.3 and I get a ping sound after 60 seconds and it stops running.

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

That ping sound is probably an error message. Yes, there is a price for that speed. I was just going to post the one possible problem. My routine uses more memory than the three sigmas did. I have Manjaro Linux. Linux is much more efficient with memory than Windows is, so that is why it works here. Did you get it to work with n = 300? Do not forget to restart mathematica to clear the memory.

Someday, you will migrate over to linux. It is just a question of time. Do not worry about that code being unfamiliar to you at this point. If we have time I will show an example of why it works tomorrow.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

Hmm, I don't have a computer with Linux at the moment. I am at uni at the moment so I cannot try the code for smaller n. Is there any way of doing this on a Windows machine, maybe with another program or a newer version of Mathematica?

I just saw you said you used Manjaro. Doesn't that mean the code needs to be modified first before using it in Mathematica?

*Last edited by zetafunc (2016-11-20 21:29:33)*

New: Integration Problem | Adding Fractions

Popular: Continued Fractions | Metric Spaces | Duality

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,752

Manjaro is the name of the Linux distro I use. Mathematica runs the same commands on all operating systems. I use 11.0 but that may not make any difference. I will work on another less memory intensive solution as soon as I get in tomorrow. Sorry to have to bug out but I need to get ready to leave.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline