Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

For ye Maths and Programming wizards

  • 07-06-2000 1:32pm
    #1
    Closed Accounts Posts: 492 ✭✭


    Heres a puzzle that a friend and I were trying to work out last night, we were very drunk smile.gif

    We all know the term Square Root and call functions in most languages to implement it on a certain number. But can anyone actually figure out who it works. Can anyone actually define in simple steps what a number has to go through to derive the square root of that number.

    Is there a simple algorithm to represent this function????????????


Comments

  • Closed Accounts Posts: 202 ✭✭Karla


    The easiest way is to loop through a load of numbers, squaring it, and seeing if it's the same as your given number. Of course, that's only gonna work for ints.

    You can also use the Dividing and Averaging method:
    Use the above method to see which number is closest to the actual square root of the number i.e.
    To get the square root of 40 try 6X6=36, 7X7=49, 6X6 is closest.
    Now you know that the square root of 40 starts with a 6 followed by whatevers after the decimal point.
    Now divide 40 by 6 to the nearest 10th. 40/6 = 6.6
    Get the average of 6 and 6.6 then square that.

    Repeat.



  • Closed Accounts Posts: 492 ✭✭Pretence


    Won't you just get an infinite loop using that method..........no??


  • Closed Accounts Posts: 344 ✭✭shank


    Glad I'm not one of your drinkin buddies wink.gif


  • Registered Users, Registered Users 2 Posts: 6,660 ✭✭✭Blitzkrieger


    I think there's a formula but it's very long-winded. I think most programs look up a table like you get in log books (only bigger)


  • Registered Users, Registered Users 2 Posts: 2,518 ✭✭✭Hecate


    and they say drink kills braincells

    I remember being in the pub with some guy who was quite sloshed, for want of a better word, and spent the whole night roaring out the cube roots of real and integer numbers.

    You could say the craic was 90.6879920111 smile.gif


  • Advertisement
  • Closed Accounts Posts: 53 ✭✭riam


    see below...............
    didnt type this had it saved from before

    _____________
    | 98 25 71

    Example of square root of 982,571


    Begin by finding the largest digit whose square is less than the first group of numbers, 98 in this case, which is greater than 9^2 = 81. So use 9 to be the leading digit of the square root. Now subtract 9^2 = 81 from the leading pair 98, getting a remainder of 17. Bring down the next pair of digits, 25, so we have 1725 get one digit for each pair of digits in the input, but after the first digit, each digit involves a trial divisor & remainder process. Take twice the "root quotient" you have found so far (twice 9 is 18) and leave room for one more digit to the right: 18x into 1725 Find a digit x as large as possible so that 18x times x is less than or equal to 1725. Now 189 times 9 is 1701, so the next digit we want will be 9 also. Subtract 1701 from 1725: 1725 - 1701 = 24
    and bring down the last two digits to put with the 24:
    2471
    The last trial divisor is twice the "root" extracted so far, twice 99 is 198, with one additional digit:
    198x into 2471 goes x times
    this can only go one time:
    2471 - 1981 = 490
    991^2 = 982081
    982571 - (991^2) = 490
    sqrt(982571) = 991.2471941952723630922423...


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    I recall years ago someone explaining to me that the square root can be done in assembly using binary and a cool formula. Or was it logs? I forget. I just remember it was kind of cool and long winded and something my brain didn't want to remember.

    It didn't use the method above, it had something to do with shifting bits.


  • Registered Users, Registered Users 2 Posts: 625 ✭✭✭Vincent


    All this numbers are giving me a headache smile.gif


  • Closed Accounts Posts: 492 ✭✭Pretence


    I agree, not the well defined, SIMPLE smile.gif, algorithm I was hoping for.

    Good though......


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    Originally posted by Hecate:
    You could say the craic was 90.6879920111 smile.gif

    On a Pentium perhaps smile.gif

    Al.



  • Advertisement
Advertisement