@rajeev kumar

in babylonian method.. initial approx shud be an over estimate of ur square
root??

u taking it as 2..

isn't a wrong assumption?


On Tue, Aug 30, 2011 at 9:36 PM, aditya kumar
<aditya.kumar130...@gmail.com>wrote:

> let u have to find the square root of s .
> a=sqrt(s) ;
> a^2=s ;
> 2(a^a)=s+a^2 ;
> a=(s+a^2)/2a ;
>
> after 20th iteration you will get more approximated value .
> hopefully it will help .:)
>
>
> On Tue, Aug 30, 2011 at 9:14 PM, teja bala <pawanjalsa.t...@gmail.com>wrote:
>
>> @aditya kumar
>> Will u plz explain the logic involved here...?
>>
>> On Tue, Aug 30, 2011 at 7:40 PM, aditya kumar <
>> aditya.kumar130...@gmail.com> wrote:
>>
>>> void getSquareRoot(float s)
>>>  {
>>>   float a=s;
>>>    int i=0;
>>>   for(i=0;i<20;i++)
>>>   {
>>>   a=(s+a*a)/(2*a);
>>>  }
>>> printf("square root is %f",a);
>>>  }
>>>
>>> On Tue, Aug 30, 2011 at 6:00 PM, Sanjay Rajpal <srn...@gmail.com> wrote:
>>>
>>>> Binary Search kind of mathod is useful here :
>>>>
>>>> float SquareRoot(float n,float start,float end)
>>>> {
>>>> float s=(start+end)/2;
>>>> if(n - sqr(s) < 0.001) && (n - sqr(s) > -0.001))
>>>>    return (end+start)/2;
>>>> else if(sqr(s) > n)
>>>>        return SquareRoot(n,0.0,s);
>>>> else
>>>>        return SquareRoot(n,s,end);
>>>> }
>>>>
>>>> Sanju
>>>> :)
>>>>
>>>>
>>>>
>>>> On Tue, Aug 30, 2011 at 3:25 AM, UTKARSH SRIVASTAV <
>>>> usrivastav...@gmail.com> wrote:
>>>>
>>>>> i don't whethe you have studied a subject cbnst from that use newton
>>>>> raphson method
>>>>>
>>>>>
>>>>> On Tue, Aug 30, 2011 at 2:39 AM, Ankuj Gupta <ankuj2...@gmail.com>wrote:
>>>>>
>>>>>> U can use binary search method
>>>>>>
>>>>>> On Aug 30, 1:56 pm, Rajeev Kumar <rajeevprasa...@gmail.com> wrote:
>>>>>> > use Babylonian method(Efficient) algrithm..............
>>>>>> > Refer :
>>>>>> http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylo.
>>>>>> ..
>>>>>> >
>>>>>> > public *void* getSquareRoot(double s) {
>>>>>> >   double Xn = 2.0;
>>>>>> >   double lastXn = 0.0;
>>>>>> >   while (Xn != lastXn) {
>>>>>> >    lastXn = Xn;
>>>>>> >    Xn = (Xn + s / Xn) / 2.0;
>>>>>> >   }
>>>>>> >   return Xn;
>>>>>> >  }
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > On Tue, Aug 30, 2011 at 1:49 PM, Ankur Garg <ankurga...@gmail.com>
>>>>>> wrote:
>>>>>> > > @techcoder
>>>>>> >
>>>>>> > > Making an array of 32768 or INT_MAX will make ur compiler cry
>>>>>> >
>>>>>> > > Also ur case doesnt handle the scenario where square root is a
>>>>>> decimal
>>>>>> > > number
>>>>>> >
>>>>>> > > On Tue, Aug 30, 2011 at 1:35 PM, tech coder <
>>>>>> techcoderonw...@gmail.com>wrote:
>>>>>> >
>>>>>> > >> the sqrt of 32 bit number can't be more than 16 bits.
>>>>>> >
>>>>>> > >> have an array of 2^16 elemnts wtih elemts 1 2 3 4 5 .... 32768 .
>>>>>> >
>>>>>> > >> now apply binary search
>>>>>> > >> i=a[mid]    where mid=(lower+upper)/2
>>>>>> >
>>>>>> > >> if(i*i==num)
>>>>>> > >> i is the sqrt
>>>>>> >
>>>>>> > >> increment lower and upper accordingly as we do in binary search
>>>>>> >
>>>>>> > >> so order is Ologn    where n=2^16
>>>>>> >
>>>>>>  > >> On Tue, Aug 30, 2011 at 11:37 AM, Raghavan <its...@gmail.com>
>>>>>> wrote:
>>>>>> >
>>>>>> > >>> how to design this logic effectively?
>>>>>> >
>>>>>> > >>> double squareRoot(int num){
>>>>>> >
>>>>>> > >>> }
>>>>>> >
>>>>>> > >>> --
>>>>>> > >>> Thanks and Regards,
>>>>>> > >>> Raghavan KL
>>>>>> >
>>>>>> > >>>  --
>>>>>> > >>> You received this message because you are subscribed to the
>>>>>> Google Groups
>>>>>> > >>> "Algorithm Geeks" group.
>>>>>> > >>> To post to this group, send email to algogeeks@googlegroups.com
>>>>>> .
>>>>>> > >>> To unsubscribe from this group, send email to
>>>>>> > >>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> > >>> For more options, visit this group at
>>>>>> > >>>http://groups.google.com/group/algogeeks?hl=en.
>>>>>> >
>>>>>> > >>  --
>>>>>> > >> You received this message because you are subscribed to the
>>>>>> Google Groups
>>>>>> > >> "Algorithm Geeks" group.
>>>>>> > >> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> > >> To unsubscribe from this group, send email to
>>>>>> > >> algogeeks+unsubscr...@googlegroups.com.
>>>>>> > >> For more options, visit this group at
>>>>>> > >>http://groups.google.com/group/algogeeks?hl=en.
>>>>>> >
>>>>>> > >  --
>>>>>> > > You received this message because you are subscribed to the Google
>>>>>> Groups
>>>>>> > > "Algorithm Geeks" group.
>>>>>> > > To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> > > To unsubscribe from this group, send email to
>>>>>> > > algogeeks+unsubscr...@googlegroups.com.
>>>>>> > > For more options, visit this group at
>>>>>> > >http://groups.google.com/group/algogeeks?hl=en.
>>>>>> >
>>>>>> > --
>>>>>> > Thank You
>>>>>> > Rajeev Kumar
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *UTKARSH SRIVASTAV
>>>>> CSE-3
>>>>> B-Tech 3rd Year
>>>>> @MNNIT ALLAHABAD*
>>>>>
>>>>> --
>>>>>  You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to