.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Space Empires: IV & V (http://forum.shrapnelgames.com/forumdisplay.php?f=20)
-   -   OT: Interesting math problem... (http://forum.shrapnelgames.com/showthread.php?t=20971)

Jack Simth September 23rd, 2004 02:25 AM

Re: OT: Interesting math problem...
 
Narf: Mostly using an iteritive Version of the function I posted earlier; although it does have issues if you feed it 0 or a negative number. There is no cut and dry one line, one pass equation to get a square root using the basic four functions (*/+-)

Kamog: that method works based on geometry. First, consider a 1x1 square of selected numerals:
<font class="small">Code:</font><hr /><pre>
1
</pre><hr />
Notice that there is one 1. In order to expand the square to a 2x2 grid, you need to add in 3 places: one above (or below) the existing 1, one left (or right) of the one, and another to fill in the corner three of them:
<font class="small">Code:</font><hr /><pre>
33
13
</pre><hr />
Suppose that we want to expand it further to a 3x3; we need to add two above (or below), two to the left (or right) and one in the corner 5 of them:
<font class="small">Code:</font><hr /><pre>
555
335
135
</pre><hr />
To generalize this, to get a square of size (N+1)x(N+1) from a square of size NxN, you need to add 2*N + 1 squares. (note that this works from a 0x0 - 2*0 + 1 = 1). In subtracting progressivly greater odd numbers, you are reversing the process - first you take out one square:
<font class="small">Code:</font><hr /><pre>
555
335
35
</pre><hr />
Then you take out three squares:
<font class="small">Code:</font><hr /><pre>
555
5
5
</pre><hr />
Then you take out five squares:
<font class="small">Code:</font><hr /><pre>



</pre><hr />
Once you are all out of squares, you are done.

However, those squares could also represent numbers just as easily.


narf poit chez BOOM September 23rd, 2004 03:57 AM

Re: OT: Interesting math problem...
 
Ok, so computer's use an iteritive function when you use 64^0.5?

Oh well, didn't think there would be a one-line equation.


All times are GMT -4. The time now is 12:25 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.