It is currently Tue May 06, 2025 7:40 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2  Next
Author Message
Offline
 Post subject: Arithmetic problem from Tobaku Haouden Zero.
Post #1 Posted: Tue Jul 19, 2011 7:30 pm 
Gosei
User avatar

Posts: 1848
Location: Bellevue, WA
Liked others: 90
Was liked: 837
Rank: AGA 5d
KGS: Capsule 4d
Tygem: 치킨까스 5d
I'm reading this manga called 'Tobaku Haouden Zero', which is very similar to Kaiji or the SAW movies. Anyways [spoilers from this point on], in one of the games the protagonist Zero has to face, he's managed to figure out that essentially he needs to determine the 9th and 10th decimal place of √2. He already knows up to the 8th decimal place (apparently due to some Japanese mnemonic). So given that he knows up to 1.41421356, what is the quickest/most efficient way for Zero to figure out the next two digits, 1.41421356xx? He has no calculator, just paper and pencil and 20 other people with him in the room worried about getting impaled by spears if Zero can't solve this problem in under 25 minutes. I'll post what Zero did later.

Image


This post by Solomon was liked by: Monadology
Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #2 Posted: Tue Jul 19, 2011 9:34 pm 
Gosei
User avatar

Posts: 1744
Liked others: 704
Was liked: 288
KGS: greendemon
Tygem: greendemon
DGS: smaragdaemon
OGS: emeraldemon
Dunno if there's a more clever way, but here's what I'd do:

let a = 1.41421356
we want to find some b such that
(a+b)^2 = 2
a^2 + 2ab + b^2 = 2
2ab + b^2 = 2-a^2
b(2a + b) = 2 - a^2

At this point I would just use binary search on b, starting with 50e-9. Then I have 100 numbers to search, so I have to do at most log_2 (100) = 7 checks.
total arithmetic:
2 - a^2 and 2*a are precomputed, 2 multiplications
Each step then requires b*(2a + b) -> 1 add and 1 multiply

Total: 9 multiplications, 7 adds (and 7 compares).

I have no idea if this is optimal, but I'm pretty confident I could do 9 long multiplications in 25 minutes.

If the 20 people in the room are willing to help, we can break the interval into chunks to get it done even faster. i.e. if we break the interval into 20 regions of 5, each person only has to do 2 or 3 multiplications. Although realistically you'd be better off breaking people into small groups and having 1 person calculate, and 2 or 3 watch for miscalculations... so maybe 10 pairs, each assigned 10 numbers to cover.

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #3 Posted: Tue Jul 19, 2011 10:56 pm 
Judan
User avatar

Posts: 5546
Location: Banbeck Vale
Liked others: 1104
Was liked: 1457
Rank: 1D AGA
GD Posts: 1512
Kaya handle: Test
emeraldemon wrote:
...
(a+b)^2 = 2...


I think you're a pincushion. :lol:

_________________
Help make L19 more organized. Make an index: https://lifein19x19.com/viewtopic.php?f=14&t=5207

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #4 Posted: Tue Jul 19, 2011 11:54 pm 
Lives with ko
User avatar

Posts: 299
Liked others: 49
Was liked: 17
Rank: KGS 10k DGS 8k
GD Posts: 396
The fatest is to know the following by heart : 1.414213562373, if I'm not mistaken :)

Emeraldemon idea seems fine. Since b^2 is of order 10^18, we should be able not to take it into account in the calcul and just solve 2ab = 2 - a^2.

I recall too that Newton's method leads to iterating : u_{n + 1} = 1/2 * (u_n - 2/u_n), which doubles the number of decimals each step. Starting from u_n = 1,41421356, we have at least 5 correct decimals. I didn't check because baby's whinning, but it's likely to be the same calcul than Emeraldemon's modified idea.


Where could I find scans from this manga ?


This post by Tryphon was liked by: perceval
Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #5 Posted: Wed Jul 20, 2011 5:33 am 
Gosei
User avatar

Posts: 2116
Location: Silicon Valley
Liked others: 152
Was liked: 330
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
I had dreams about trying to solve this last night using some bastardized version of the technique I skim-read when we had that thread on the soroban...

Is there a method for doing a square root like you do long division? If there is I never learned it.

_________________
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #6 Posted: Wed Jul 20, 2011 5:55 am 
Lives with ko
User avatar

Posts: 193
Location: Trondheim, Norway
Liked others: 76
Was liked: 29
Rank: 2d EGF and KGS
GD Posts: 1005
Universal go server handle: sverre
How I would solve it:

Binary search for two digits is about 7 steps (2**7 = 128)
Multiplication of two 10-digit numbers is ~200 operations.
In total ~1400 operations, I feel I could probably do that in 25 minutes.

Using the fact that we have 20 people (do we have pen and paper for everyone?), I would do a 20-ary search (or a 10-ary search with an extra backup for each multiplication), which would take only two steps. We should have enough time to double-check the answer too, I hope.

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #7 Posted: Wed Jul 20, 2011 5:59 am 
Lives in sente
User avatar

Posts: 921
Liked others: 401
Was liked: 164
Rank: German 2 dan
daniel_the_smith wrote:
Is there a method for doing a square root like you do long division? If there is I never learned it.


Yes, there is. I have to look it up, though.

_________________
A good system naturally covers all corner cases without further effort.

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #8 Posted: Wed Jul 20, 2011 6:09 am 
Gosei
User avatar

Posts: 1744
Liked others: 704
Was liked: 288
KGS: greendemon
Tygem: greendemon
DGS: smaragdaemon
OGS: emeraldemon
Joaz Banbeck wrote:
emeraldemon wrote:
...
(a+b)^2 = 2...


I think you're a pincushion. :lol:



hmm?

edit:
let a = 1.41421356
we want some 1.41421356xx such that
1.41421356xx = sqrt(2)
let b = xx (i.e. some small number)
a+b = sqrt(2)
square both sides:
(a+b)^2 = 2

did I go wrong somewhere?

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #9 Posted: Wed Jul 20, 2011 6:52 am 
Gosei
User avatar

Posts: 2116
Location: Silicon Valley
Liked others: 152
Was liked: 330
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
Harleqin wrote:
daniel_the_smith wrote:
Is there a method for doing a square root like you do long division? If there is I never learned it.


Yes, there is. I have to look it up, though.


Hm, it seems to me that the current suggestion is equivalent: http://www.therthdimension.org/MathScie ... eroot2.htm

(that is, the current suggestion seems to just be an expansion of the "find the largest y such that..." step)

I will not be doing that in my head, that's for sure. Every additional digit requires multiple multiplications of a number one digit longer than the prior digit, which doesn't seem at all practical. I wonder how hard newton's method is to do by hand?

_________________
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #10 Posted: Wed Jul 20, 2011 7:11 am 
Gosei
User avatar

Posts: 2116
Location: Silicon Valley
Liked others: 152
Was liked: 330
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
I looked up Newton's method.

It seems one more iteration should give more than enough digits:

.5 * (1.41421356 + 2 / 1.41421356)

I'm highly confident I could solve that correctly in 25 minutes. Deriving it, maybe not. :)

_________________
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #11 Posted: Wed Jul 20, 2011 7:25 am 
Lives in sente
User avatar

Posts: 1326
Liked others: 14
Was liked: 153
Rank: German 1 Kyu
We can apply an algorithm used for quick search in a sorted list.

xx can be between "00" and "99", which is 100 elements.
But to prevent a mistake with rounding the 11th digit, we have to consider yyy between "000" and "999", which is 1000 elements.

Divide 1000 by 2, and we get 500. The 500th element of the list is 499.

1,41421356499 ^ 2 is greater than 2.

So yyy must be in the lower part of the 500-element-list.
500 divided by 2 is 250, the 250th element is 249.

1,41421356249 ^ 2 is greater than 2.

Again, yyy must be in the lower part of the list.
250 divided by 2 is 125.

1,41421356124 ^ 2 is smaller than 2.

We choose the upper part of the remaining list.
(250 + 125) / 2 = 187.5.

1,41421356188 ^ 2 is smaller than 2.

We choose the upper part of the remaining list.
(250 + 188) / 2 = 219.

1,41421356219 ^ 2 is smaller than 2.

We choose the upper part of the remaining list.
(250 + 219) / 2 = 235.

1,41421356235 ^ 2 is smaller than 2.

We choose the upper part of the remaining list.
(250 + 235) / 2 = 242.5.

1,41421356243 ^ 2 is greater than 2.

We choose the lower part of the remaining list.
(243 + 235) / 2 = 239.

1,41421356239 ^ 2 is greater than 2.

We choose the lower part of the remaining list.
(243 + 239) / 2 = 237.

1,41421356237 ^ 2 is smaller than 2.

So we have found that yyy can be 237, or 238, or 239, but we can be sure that xx = 23.

+ + + + + + + + + + + + + +

Don't know if I would be able to do this in 25 minutes, but perhaps there is some sort of shortcut.

1,41421356249 ^2 is 2,0000000003

So we could dramatically reduce the size of the following lists, e.g. have the next try with 1,41421356233.

+ + + + + + + + + + + + + +

Or - if the size of the list in question is smaller than 21 * 5 = 105 - perhaps the 20 other people can help with doing the arithmetics in steps of 0,00000000005.

_________________
The really most difficult Go problem ever: https://igohatsuyoron120.de/index.htm
Igo Hatsuyōron #120 (really solved by KataGo)

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #12 Posted: Wed Jul 20, 2011 7:49 am 
Judan
User avatar

Posts: 5546
Location: Banbeck Vale
Liked others: 1104
Was liked: 1457
Rank: 1D AGA
GD Posts: 1512
Kaya handle: Test
emeraldemon wrote:
Joaz Banbeck wrote:
emeraldemon wrote:
...
(a+b)^2 = 2...


I think you're a pincushion. :lol:



hmm?

edit:
let a = 1.41421356
we want some 1.41421356xx such that
1.41421356xx = sqrt(2)
let b = xx (i.e. some small number)
a+b = sqrt(2)
square both sides:
(a+b)^2 = 2

did I go wrong somewhere?


Nope. My misunderstanding.

_________________
Help make L19 more organized. Make an index: https://lifein19x19.com/viewtopic.php?f=14&t=5207

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #13 Posted: Wed Jul 20, 2011 8:39 am 
Lives with ko
User avatar

Posts: 223
Location: Denver CO
Liked others: 16
Was liked: 83
Rank: SDK
GD Posts: 156
Is the 8th digit from the mnemonic rounded up? So instead of the 6th-10th digits being 356ab it could actually be 355yz where y>4.

Wouldn't that double your search space if you weren't sure about that 8th digit? I know it is only one more high/low operation but it rattled through my brain.

Bruce "1+1=3 for large values of 1" Young

_________________
Currently reading: Plutarch, Cerebus, and D&Q 25th Anniversary

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #14 Posted: Wed Jul 20, 2011 8:45 am 
Gosei
User avatar

Posts: 2116
Location: Silicon Valley
Liked others: 152
Was liked: 330
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
daniel_the_smith wrote:
... 2 / 1.41421356 ...


Realized driving to work that that is not an easy division problem... Fortunately, Newton's method can solve that, too: http://en.wikipedia.org/wiki/Division_(digital)#Fast_division_methods

_________________
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #15 Posted: Wed Jul 20, 2011 9:00 am 
Honinbo

Posts: 9552
Liked others: 1602
Was liked: 1712
KGS: Kirby
Tygem: 커비라고해
I bet Araban's solution takes advantage of the 20 bystanders. There are 20 possible digits (10 per x).

_________________
be immersed

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #16 Posted: Wed Jul 20, 2011 9:23 am 
Gosei
User avatar

Posts: 2116
Location: Silicon Valley
Liked others: 152
Was liked: 330
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
Kirby wrote:
I bet Araban's solution takes advantage of the 20 bystanders. There are 20 possible digits (10 per x).


Maybe I'm too pessimistic, but given 20 random adults, I'd expect maybe 10 of them to be able to get a 10 digit multiplication problem correct in 25 minutes under that kind of pressure.

_________________
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #17 Posted: Wed Jul 20, 2011 9:24 am 
Dies with sente
User avatar

Posts: 106
Location: Germany
Liked others: 64
Was liked: 7
Rank: EGF 8k
Universal go server handle: ChradH
This reminds me of an interpolation method I learned some 30 years ago :)
It gives one digit per iteration:

1.41421356 is too small (too short), and 1.41421357 is already too big,
so lets take them for lower bound 'L' and upper bound 'U', respectively.

Calculate L^2 and U^2 and see where our goal 2 lies in between:

Let x = (2 - L^2) / (U^2 - L^2) = 0.237... for values above.
Take first digit after the decimal point as the next digit of the root: 1.414213562 and repeat.

Next iteration gives 1.4142135623.

That's two (long) multiplications and one (shorter) division per iteration. As we need only the first digit of x, it might even be possible to break the multiplications off early when they have reached enough significant digits.

In any case this should be possible with pencil and paper in 25 minutes. I used a calculator, of course :)
A really cool solution would use those 20 people around :lol:

_________________
To sig or not to sig, that is the question.

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #18 Posted: Wed Jul 20, 2011 9:29 am 
Lives in sente
User avatar

Posts: 1326
Liked others: 14
Was liked: 153
Rank: German 1 Kyu
Kirby wrote:
I bet Araban's solution takes advantage of the 20 bystanders. There are 20 possible digits (10 per x).

If there are enough pencils and paper, parallel processing might be possible.

There are 20 helpers, so let them calculate the squares with

xx = 00, 05, 10, ... , 95.

After the first run, the hero will find that 20 gives a result below 2, 25 a result above.

For the second run, the hero can let his helpers calculate in steps of .4, i. e.
20.4, 20.8, 21.2, ..., with the result that 23.6 is below and 24.0 is above 2.

The third, and decisive, run is the one for the hero, who calculates 23.9, with a result above 2.

So he can be sure that xx is 23.

_________________
The really most difficult Go problem ever: https://igohatsuyoron120.de/index.htm
Igo Hatsuyōron #120 (really solved by KataGo)

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #19 Posted: Wed Jul 20, 2011 10:54 am 
Lives with ko

Posts: 198
Liked others: 4
Was liked: 23
Rank: lol
KGS: DrBobC
Tygem: 35kyu
I think you can bastardise Taylors theorem for this.
Take given: 1.41421356

1.41421356 - square it..
then turn the 56 into 57 - square it ( with one f the helpers)
then turn 56 into 565 - square it..
compare answers to 2 then interpolate and repeat with increasing precision...



it's like playing the "hi lo guess a number game". Should get it out in about 7 squares..

Top
 Profile  
 
Offline
 Post subject: Re: Arithmetic problem from Tobaku Haouden Zero.
Post #20 Posted: Wed Jul 20, 2011 5:59 pm 
Tengen

Posts: 4382
Location: Caldas da Rainha, Portugal
Liked others: 499
Was liked: 733
Rank: AGA 3k
GD Posts: 65
OGS: Hyperpape 4k
This could be personal preference, but it feels easier to use the formula for square of sums, then subtract and do division, using a lot of "safe" approximations.

[1] (a + b)^2 = a^2 + 2ab + b^2.

[2] a = 1.41421356

[3] a ^ 2 = 1.99999999328

[4] 2 - a ^ 2 = 67.2... * 10 ^-9 (as far as the calculation is concerned, you can forget the -9).

[5] 67.2 / 2a ≈ 23

[6] b = 2.3 * 10^-9

=========

At [3], the b^2 term is extremely small. Unless 2 - a^2 looks wrong, you can ignore it.

You can do [5] with all the digits of the 67.2... term, as well as all the digits of a. But you're almost certainly not going to need them all. I'd start with 67.2 / 1.41 and see whether I might need to backtrack.

_________________
Occupy Babel!

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 39 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group