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 8467003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:30:58+00:00 2026-06-10T15:30:58+00:00

I’ve noticed that odeint uses very little memory when compared to my implementation of

  • 0

I’ve noticed that odeint uses very little memory when compared to my implementation of the RK4 algorithm or Mathematica. For the same step size, odeint uses about 3.11GB while my program uses 7GB and with Mathematica, I have to manually increase the pagefile size to 40GB or else it runs out of memory. (Edit: CPU usage is only 18%)

I am curious on how this is possible because when I save the results, the data file is almost the same size in all three cases.

However, when it comes to execution time, odeint seems an order of magnitude slower than either my program or Mathematica. Is this tradeoff normal? I do things the super noob way.

Edit:2
** Step Size vs Execution Time **

  • 0.0005=2:55.59 ~ 24.44hrs for 500 steps
  • 0.001=1:29.14 ~ 12.5hrs for 500 steps
  • 0.005= 0:17.19~ 2.5hrs for 500 steps.
  • 0.01= 8.34 ~ 1hr10min for 500 steps

For example:

void Classical(vector<vector<double> >& u1,vector<vector<double> >& u2,vector<vector<double> >& phi1,vector<double>& delta,vector<vector<double> >& theta,vector<vector<double> >& phi2, vector<double>& Gamma,vector<double>& z,double h,double u10,double u20,double theta_initial){

for(int i=0;i<delta.size();++i){ 

        double v1=u10;
        double v2=u20;
        double ph1=0.0;
        double ph2=0.0;
        double angle=delta[i]; //OK



    u1.push_back ( vector<double>() );
    u2.push_back ( vector<double>() );
    phi1.push_back ( vector<double>() );
    phi2.push_back ( vector<double>() );
    theta.push_back ( vector<double>() );

        for(int j=0;j<z.size();++j){



            double k1=0.0; double k2=0.0;double k3=0.0;double k4=0.0;
            double L1=0.0; double L2=0.0;double L3=0.0;double L4=0.0;
            double m1=0.0; double m2=0.0;double m3=0.0;double m4=0.0;
            double n1=0.0; double n2=0.0;double n3=0.0;double n4=0.0;                               


            k1=h*(v2*v2-1.0)*cos((angle));
            L1=h*( (2.0/(1.0-(v2*v2))) - (1.0/(v2*v2)) )*Gamma[i];
            m1=h*(1.0/(1.0-(v2*v2)))*Gamma[i];
            n1=h*(1.0/((v2*v2)))*Gamma[i];

            k2=h*((v2+k1/2)*(v2+k1/2)-1)*cos(((angle+L1/2)));
            L2=h*( (2.0/(1-((v2+k1/2)*(v2+k1/2)))) - (1/((v2+k1/2)*(v2+k1/2))) )*Gamma[i];
            m2=h*(1/(1-((v2+k1/2)*(v2+k1/2))))*Gamma[i];
            n2=h*(1/(((v2+k1/2)*(v2+k1/2))))*Gamma[i];

            k3=h*((v2+k2/2)*(v2+k2/2)-1)*cos(((angle+L2/2)));
            L3=h*( (2.0/(1-((v2+k2/2)*(v2+k2/2)))) - (1/((v2+k2/2)*(v2+k2/2))) )*Gamma[i];
            m3=h*(1/(1-((v2+k2/2)*(v2+k2/2))))*Gamma[i];
            n3=h*(1/(((v2+k2/2)*(v2+k2/2))))*Gamma[i];

            k4=h*((v2+k3)*(v2+k3)-1)*cos(((angle+L3)));
            L4=h*( (2.0/(1-((v2+k3)*(v2+k3)))) - (1/((v2+k3)*(v2+k3))) )*Gamma[i];
            m4=h*(1/(1-((v2+k3)*(v2+k3))))*Gamma[i];
            n4=h*(1/(((v2+k3)*(v2+k3))))*Gamma[i];


            v2=v2+(k1/6)+(k2/3)+(k3/3)+(k4/6); 
            angle=angle + (L1/6)+(L2/3)+(L3/3)+(L4/6);
            ph1=ph1+(m1/6)+(m2/3)+(m3/3)+(m4/6); 
            ph2=ph2+(n1/6)+(n2/3)+(n3/3)+(n4/6);

            v1=sqrt(1.0-(v2*v2));

            u1[i].push_back(v1);
            u2[i].push_back(v2);
            theta[i].push_back(angle);
            phi1[i].push_back(ph1);
            phi2[i].push_back(ph2);
        }


}

}

  • 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-10T15:31:00+00:00Added an answer on June 10, 2026 at 3:31 pm

    I think you should compile your programs in release modus to enable compiler optimization. odeint uses lots of template code which is quite slow when compiled in debug modus. The performance will be increaced by orders of magnitude in release modus.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post

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.