Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7890659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:24:46+00:00 2026-06-03T06:24:46+00:00

I have been looking around online for a while now for methods of integration

  • 0

I have been looking around online for a while now for methods of integration for a physics engine I am trying to code for fun (gotta love the nerdiness there :P). I have found Euler’s method, RK4, and Verlet (as well as the time corrected version). I have also been trying to come up with some of my own methods. I was wondering if you knew of any others that you found intuitive or helpful. Thanks.

EDIT: Thanks for all of your help so far. As for clarification: perhaps I do mean numeric integration. Surprisingly, in all my research, I have not found so much as the technical NAME for what I am trying to do! Perhaps describing my specific problem will make my question more clear. Lets say I want to simulate a ball moving through a circular (or spherical once I implement 3d) gravitational field. This ball will encounter force vectors which can be used to calculate a corresponding acceleration vector for the point the ball is at on that specific tick. From your physics class, you know that velocity = acceleration * time but my problem is that the ball is technically on that point for only an instant, represented mathematically in calculus by dt. Obviously, I cannot use an infinitesimally small number in C++ so I must approximate the solution using methods of instantaneous integration (a term I heard in some reading but I could be completely wrong about) or what you think is called numerical integration (you are probably right so I changed the title).

Here is my (successful) attempt at implementing the Euler method of numerical integration:

    //For console output. Note: I know I could just put "using namespace std;" but I hate doing that.
    #include <iostream>
    using std::cout;
    using std::system;
    using std::endl;

    //Program entry
    int main (void)
    {
        //Variable decleration;
        double time = 0;
        double position = 0;
        double velocity = 0;
        double acceleration = 2;
        double dt = 0.000001; //Here is the "instantanious" change in time I was talking about.
        double count = 0; //I use count to make sure I am only displaying the data at whole numbers.

        //Each irritation of this loop is one tick
        while (true)
        {

            //This next bit is a simplified form of Euler's method. It is what I want to "upgrade"
            velocity += acceleration * dt;
            position += velocity * dt;

            if (count == 1/dt) //"count == 1/dt" will only return true if time is a whole number.
            {

                //Simple output to console
                cout << "Time: " << time << endl;
                cout << "Position: " << position << endl;
                cout << "------------------" << endl;
                system ("pause");

                count = 0; //To reset the counter.

            }

            //Update the counters "count" and "time"
            count++;
            time += dt;

        }
        return 1; //Program exit
    }

Because the acceleration is constant and this differential is actually solvable (why I am using it to test, the solution is position = time ^ 2, this is fairly accurate but if you make it a bit more complicated by, for example, making the acceleration change over time, the algorithm loses accuracy extremely rapidly. Again, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:24:48+00:00Added an answer on June 3, 2026 at 6:24 am

    You have a second order differential equation (ODE) x”=f(x,x’,t). x can be a vector and x’ and x” are the first and the second derivative with respect to the time. In your case x is the position, x’ is the velocity and x” is the acceleration. Usually one transforms this second order ODE into a first ODE by introducing X=x,Y=x’ and you obtain

    X’=Y
    Y’=f(X,Y)

    Then you can use the classical schemes for solving ODEs like Runge-Kutta, Dormand-Prince, Adams-Bashforth, …

    Many of these methods are implemented in odeint which is quite easy to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking around online, doing research into how to use blocks. I
I have been looking around online at how to post a UIImage to the
I have been looking around for awhile now and I can't seem to find
I have been looking around online to try to find a complete solution but
I have been looking around online for an answer to this question for several
I have been looking around for a while, and cant seem to find the
I have been looking around the Tank auth code to see how things are
I have been looking around for a few hours trying to figure out how
I have been looking around for a while and not found anything useful, also
I have been looking around for some time now, but can't seem to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.