Calculating integral of earths orbit but with visual basic.

In summary, the conversation discusses how to calculate the definite integral of a program that animates the Earth's orbit using Newton's laws. The extended linear interpolation formula is mentioned and the steps for calculating the integral are suggested. The use of the "*" operator and the "Math.Pow" function in Visual Basic are also mentioned as tools to help with the calculation.
  • #1
Lengalicious
163
0

Homework Statement


Ok for starters, I wasn't entirely sure whether this was supposed to go under physics or comp sci, this is a 'physics' problem I believe but done through visual basic, anyways.

So I have a program where the Earth is animated to orbit the sun based on Newtons laws, I need to calculate the definite integral from X = start of orbit, to X = 0 ∫ Y(x) dx based on the linear interpolation formula shown below.

Homework Equations



Extended linear interpolation formula: 1/2*(f(x1) + f(x2))*h + 1/2*(f(x3) + f(x4))*h + . . + 1/2*(f(xn-1) + f(xn))*h

where h is supposed to be x2-x1 for the 1st term then x3-x2 for the next term etc.

The Attempt at a Solution



Please note that before this question I had a question to integrate ∫ 1/R(t)2 dt from where the Earth starts to X=0 before the one I'm asking and I achieved this by doing a sum within the While loop, ie.
Code:
While x > 0

Sum = Sum + Function

End While

Then taking away the 1/2*(1st + last) terms to adjust for the error in the extended interpolation formula.

Now for the question I'm completely stuck all I can suggest to myself is doing another summation during the loop of the function 'Y' but then I have to somehow adjust the answer so that it gives the same answer as the formula but I don't understand how to multiply each term by 'h' in visual basic? Any suggestions?
 
Physics news on Phys.org
  • #2


Hi there,

I would suggest breaking down the problem into smaller steps and tackling them one at a time. First, try to understand the extended linear interpolation formula and how it applies to your problem. Then, try to write out the steps for calculating the integral using the formula. Once you have a clear understanding of the steps, you can start implementing them in your program.

In terms of multiplying each term by "h" in Visual Basic, you can use the "*" operator to multiply two values. For example, if you have a variable "h" and a value "f(x1)", you can write it as "h * f(x1)". You can also use the built-in function "Math.Pow" to raise a value to a power, in this case "h" raised to the power of 2. So you can write it as "Math.Pow(h, 2)".

I hope this helps and good luck with your program!
 

Related to Calculating integral of earths orbit but with visual basic.

1. How do I calculate the integral of Earth's orbit using Visual Basic?

To calculate the integral of Earth's orbit using Visual Basic, you will need to use the appropriate formula and code it into your program. The formula for calculating the orbital integral is: ∫(GM/r²) dr, where G is the gravitational constant, M is the mass of the Sun, and r is the distance between the Sun and Earth at a given point in time.

2. What are the necessary inputs for calculating the integral of Earth's orbit in Visual Basic?

The necessary inputs for calculating the integral of Earth's orbit in Visual Basic are the gravitational constant, the mass of the Sun, and the distance between the Sun and Earth at a given point in time. These values can be obtained from reliable sources, such as scientific databases or textbooks.

3. Can I use Visual Basic to calculate the integral of other planets' orbits?

Yes, Visual Basic can be used to calculate the integral of other planets' orbits as long as you have the necessary inputs for the specific planet. The formula for calculating the orbital integral remains the same, but the values for G, M, and r will differ depending on the planet.

4. How accurate is the calculation of the integral of Earth's orbit in Visual Basic?

The accuracy of the calculation of the integral of Earth's orbit in Visual Basic will depend on the precision of the values used for the inputs and the coding of the program. To ensure greater accuracy, it is important to use the most updated and precise values for G, M, and r, and to double-check the coding of the program for any errors.

5. Are there any other programming languages that can be used to calculate the integral of Earth's orbit?

Yes, there are other programming languages that can be used to calculate the integral of Earth's orbit, such as Python, C++, and Java. The choice of language will depend on the programmer's preference and familiarity, as well as the specific requirements of the project.

Similar threads

  • Advanced Physics Homework Help
Replies
0
Views
613
  • Advanced Physics Homework Help
Replies
5
Views
2K
  • Advanced Physics Homework Help
Replies
24
Views
1K
  • Advanced Physics Homework Help
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
896
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Advanced Physics Homework Help
Replies
4
Views
2K
  • Advanced Physics Homework Help
Replies
1
Views
1K
Back
Top