none
Help need to compute the Gravitational force between Sun and Earth RRS feed

  • Question

  • Hi,
    I am trying to create a little basic program in small basic, that will compute
    The Gravitational force between Sun and Earth.

                        For this i need Newton Gravitational law:

                               F= G x ( m1 x m2 ) / r^2

        where F = gravitational force
        where G = is the gravitational constant, approximately 6.674×10^−11
      where m1 = mass of the Sun  in kg  ( see Sun in wikipedia)
      where m2 = mass of the Earth in kg
                   r = distance between Sun an Earth in meters EXPONENT 2

                                 so in small basic i have:
                     Earth_Mass = (math.Power(10,24))*5.9736    
                     Sun_Mass = (math.Power(10,30))*1.9891     
                     Distance = 149,597,870,700

                              G = (math.Power(10,-11))*6.67384

                           this is the final formula in small basic:
             F = G * (Sun_Mass*Earth_Mass) / math.Power(distance,2)

    and small basic will returned a kind of overflow error, and the my program stop.
     the numbers involved here are to big, i think...

    what can I do ?  any idea :)

    the answer must be : 3,543 x 10 exponent 22 Newtons.
    Monday, February 8, 2016 2:14 PM
    Answerer

Answers

  • Simplified version of NaochanON's solution.

    Earth_Mass[1]=5.9736
    Earth_MassPow=24  'math.Power(10,24)*5.9736    '  (kilograms)
    Sun_Mass[1]=1.9891
    Sun_MassPow=30 ' math.Power(10,30)*1.9891     '  (kilograms)
    'Distance  Sun to Earth: 149,597,870,700 meters 
    distance[1]=1.49597870700
    distancePow=11
    
    'The gravitational constant, approximately 6.674×10^−11 and denoted by the letter G 
    G[1]=6.67384
    GPow=-11
    'math.Power(10,-11)*6.67384
    'GRAVITATIONAL FORMULA BY NEWTON
    'F= G x ( m1 x m2 ) / r^2
    Ff= G[1]*Earth_Mass[1]*Sun_Mass[1]/(math.power(distance[1],2))
    ForcePow = GPow+Earth_MassPow+Sun_MassPow-(2*distancePow)
    F= Ff*math.Power(10,ForcePow)  '  <---   Small basic can show this value 
    TextWindow.WriteLine(F)
    cP= Text.GetIndexOf(Ff,".")
    Ff=Ff/math.Power(10,cp-2)
    ForcePow= ForcePow+(Cp-2)
    TextWindow.WriteLine("F= "+Ff+"*10^"+ForcePow)  


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Wednesday, February 10, 2016 1:32 AM
    Answerer

All replies

  • See the answer in the other topic where you asked this:

    https://social.msdn.microsoft.com/Forums/en-US/defa0b6d-cae2-45b5-83f3-05ee7ae893de/what-is-wrong-with-this-code?forum=smallbasic#75a6a885-5912-485f-b65b-0a7c41f0c4f7


    Jan [ WhTurner ] The Netherlands

    Monday, February 8, 2016 2:28 PM
    Answerer
  • Simplified version of NaochanON's solution.

    Earth_Mass[1]=5.9736
    Earth_MassPow=24  'math.Power(10,24)*5.9736    '  (kilograms)
    Sun_Mass[1]=1.9891
    Sun_MassPow=30 ' math.Power(10,30)*1.9891     '  (kilograms)
    'Distance  Sun to Earth: 149,597,870,700 meters 
    distance[1]=1.49597870700
    distancePow=11
    
    'The gravitational constant, approximately 6.674×10^−11 and denoted by the letter G 
    G[1]=6.67384
    GPow=-11
    'math.Power(10,-11)*6.67384
    'GRAVITATIONAL FORMULA BY NEWTON
    'F= G x ( m1 x m2 ) / r^2
    Ff= G[1]*Earth_Mass[1]*Sun_Mass[1]/(math.power(distance[1],2))
    ForcePow = GPow+Earth_MassPow+Sun_MassPow-(2*distancePow)
    F= Ff*math.Power(10,ForcePow)  '  <---   Small basic can show this value 
    TextWindow.WriteLine(F)
    cP= Text.GetIndexOf(Ff,".")
    Ff=Ff/math.Power(10,cp-2)
    ForcePow= ForcePow+(Cp-2)
    TextWindow.WriteLine("F= "+Ff+"*10^"+ForcePow)  


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Wednesday, February 10, 2016 1:32 AM
    Answerer
  • :D

    KKV303


    It is written: "'As surely as I live,' says the Lord, 'every knee will bow before me; every tongue will acknowledge God.'" Romans 14:11

    Thursday, February 11, 2016 6:00 AM
    Answerer