destro014 / Numerical-Method-In-C

These are the codes done in c programming languages.
2 stars 7 forks source link

Problems with the execution time of Romberg integration.c #2

Open Physics-16 opened 10 months ago

Physics-16 commented 10 months ago

Hi, The code given for ROMBERG integration in this link "https://github.com/destro014/Numerical-Method-In-C/blob/master/romberg%20integration.c" is running successfully for the small dimensions (upto 30*30) of the romberg matrix (T[p][q]). But the problem arises with the execution time when I try to run the same code for some large diemensions (greater than 30). In those cases, the execution time becomes extremely large which seems very unusual to me. Just look at the difference:--

  1. For a romberg matrix of dimension *3232, the execution has not been completed after running the code for 258 min.**
  2. For a romberg matrix of dimension *3030, the execution time becomes 38 sec only**.

Now the question is why I need such a large dimensional Romberg matrix. I need this to get the accurate result of an integration with integrational limit starting from "0.0000000000001" to "1.0". Actually I need to do this type of numerical integration for my research project on Cosmology. More precisely, I need to include this Romberg integration code in a large code called "CLASS (Cosmic Linear Anisotropy Solving System)". That's why I need to reduce the execution time of the Romberg integration with the integrational limit given above.

So, can somebody help me out in reducing the execution time of the Romberg integration such that it can be done within a minute ??

SalonRaut7 commented 1 month ago

Hi, The code given for ROMBERG integration in this link "https://github.com/destro014/Numerical-Method-In-C/blob/master/romberg%20integration.c" is running successfully for the small dimensions (upto 30*30) of the romberg matrix (T[p][q]). But the problem arises with the execution time when I try to run the same code for some large diemensions (greater than 30). In those cases, the execution time becomes extremely large which seems very unusual to me. Just look at the difference:--

  1. For a romberg matrix of dimension *3232, the execution has not been completed after running the code for 258 min.**
  2. For a romberg matrix of dimension *3030, the execution time becomes 38 sec only**.

Now the question is why I need such a large dimensional Romberg matrix. I need this to get the accurate result of an integration with integrational limit starting from "0.0000000000001" to "1.0". Actually I need to do this type of numerical integration for my research project on Cosmology. More precisely, I need to include this Romberg integration code in a large code called "CLASS (Cosmic Linear Anisotropy Solving System)". That's why I need to reduce the execution time of the Romberg integration with the integrational limit given above.

So, can somebody help me out in reducing the execution time of the Romberg integration such that it can be done within a minute ??

Try allocating memory for the romberg matrix using malloc as: t = (float *)malloc((p + 1) sizeof(float *)); It might fix your error.