This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:spring2017:cprog:projects:pnc1 [2017/02/25 20:24] – created wedge | haas:spring2017:cprog:projects:pnc1 [2017/03/01 18:43] (current) – [Check Results] wedge | ||
---|---|---|---|
Line 80: | Line 80: | ||
An optimization to the previous process, which used **sqrt()**, this variation will do the exact same thing, but without using the **sqrt()** function. It will approximate the square root. | An optimization to the previous process, which used **sqrt()**, this variation will do the exact same thing, but without using the **sqrt()** function. It will approximate the square root. | ||
- | We know that a square root (especially a whole numbered square root), is when we have whole number factors that are squared. | + | We know that a square root (especially a whole numbered square root), is when we have whole number factors that are squared. |
- | 9*9 == 81, the square | + | < |
+ | lab46:~$ count=0; for ((i=2; i<152; i++)); do printf "[%3d] %2d " " | ||
+ | [ 2] 1 [ 3] 1 [ 4] 2 [ 5] 2 [ 6] 2 [ 7] 2 [ 8] 2 [ 9] 3 [ 10] 3 [ 11] 3 | ||
+ | [ 12] 3 [ 13] 3 [ 14] 3 [ 15] 3 [ 16] 4 [ 17] 4 [ 18] 4 [ 19] 4 [ 20] 4 [ 21] 4 | ||
+ | [ 22] 4 [ 23] 4 [ 24] 4 [ 25] 5 [ 26] 5 [ 27] 5 [ 28] 5 [ 29] 5 [ 30] 5 [ 31] 5 | ||
+ | [ 32] 5 [ 33] 5 [ 34] 5 [ 35] 5 [ 36] 6 [ 37] 6 [ 38] 6 [ 39] 6 [ 40] 6 [ 41] 6 | ||
+ | [ 42] 6 [ 43] 6 [ 44] 6 [ 45] 6 [ 46] 6 [ 47] 6 [ 48] 6 [ 49] 7 [ 50] 7 [ 51] 7 | ||
+ | [ 52] 7 [ 53] 7 [ 54] 7 [ 55] 7 [ 56] 7 [ 57] 7 [ 58] 7 [ 59] 7 [ 60] 7 [ 61] 7 | ||
+ | [ 62] 7 [ 63] 7 [ 64] 8 [ 65] 8 [ 66] 8 [ 67] 8 [ 68] 8 [ 69] 8 [ 70] 8 [ 71] 8 | ||
+ | [ 72] 8 [ 73] 8 [ 74] 8 [ 75] 8 [ 76] 8 [ 77] 8 [ 78] 8 [ 79] 8 [ 80] 8 [ 81] 9 | ||
+ | [ 82] 9 [ 83] 9 [ 84] 9 [ 85] 9 [ 86] 9 [ 87] 9 [ 88] 9 [ 89] 9 [ 90] 9 [ 91] 9 | ||
+ | [ 92] 9 [ 93] 9 [ 94] 9 [ 95] 9 [ 96] 9 [ 97] 9 [ 98] 9 [ 99] 9 [100] 10 [101] 10 | ||
+ | [102] 10 [103] 10 [104] 10 [105] 10 [106] 10 [107] 10 [108] 10 [109] 10 [110] 10 [111] 10 | ||
+ | [112] 10 [113] 10 [114] 10 [115] 10 [116] 10 [117] 10 [118] 10 [119] 10 [120] 10 [121] 11 | ||
+ | [122] 11 [123] 11 [124] 11 [125] 11 [126] 11 [127] 11 [128] 11 [129] 11 [130] 11 [131] 11 | ||
+ | [132] 11 [133] 11 [134] 11 [135] 11 [136] 11 [137] 11 [138] 11 [139] 11 [140] 11 [141] 11 | ||
+ | [142] 11 [143] 11 [144] 12 [145] 12 [146] 12 [147] 12 [148] 12 [149] 12 [150] 12 [151] 12 | ||
+ | </ | ||
+ | |||
+ | Square | ||
- | If we were checking | + | If we were checking |
- | We don't need a **sqrt()** function to tell us this, we can determine the approximate square root point ourselves- | + | We don't need a **sqrt()** function to tell us this, we can determine the approximate square root point ourselves- |
There are some important lessons at play here: | There are some important lessons at play here: | ||
Line 251: | Line 270: | ||
lab46: | lab46: | ||
==================================================================================================== | ==================================================================================================== | ||
- | range brute | + | range brute |
==================================================================================================== | ==================================================================================================== | ||
- | 128 0.000097 | + | 128 0.000179 |
- | 256 0.000238 | + | 256 0.000401 |
- | 512 0.001000 | + | 512 0.001535 |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | 16384 0.705101 | + | 16384 1.059970 |
- | 32768 2.786815 | + | 32768 4.209891 |
- | 65536 | + | 65536 |
- | | + | |
- | | + | |
- | | + | |
- | 1048576 | + | 1048576 |
- | 2097152 | + | 2097152 |
- | 4194304 | + | 4194304 |
- | 8388608 | + | 8388608 |
==================================================================================================== | ==================================================================================================== | ||
- | | + | |
==================================================================================================== | ==================================================================================================== | ||
lab46: | lab46: | ||
Line 319: | Line 338: | ||
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. | ||
+ | |||
+ | What I will be looking for: | ||
+ | |||
+ | < | ||
+ | 78: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | *: | ||
+ | </ |