Giter Site home page Giter Site logo

pijako / runge-kutta Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rand-asswad/runge-kutta

0.0 0.0 0.0 12 KB

Runge-Kutta C program, methods (RK12 and RK24) for solving ordinary differential equations, with adaptive step size.

C 99.32% Makefile 0.68%

runge-kutta's Introduction

Runge-Kutta

Runge-Kutta C program, methods (RK12 and RK24) for solving ordinary differential equations, with adaptive step size.

The program solves an ODE of the form

$ y'(t) = f(t,y(t)), \forall t\in[a,b] $

for a given point $M_0 = (t_0, y(t_0))$

We propose two examples of ODE, please feel free to add or modify an ODE after defining the right conditions.

The Runge-Kutta code can be found easily on the web. However, I decided to post my code because I had a hard time finding a RK code with adaptive step size which is very important in practice.

My code guarantees the error to be smaller than the user-defined tolerance value (it can be $10^{-6}$, just go nuts!). If the error is greater than the entered tolerance it means that you have entered a very small tolerance that reduced the step into the machine zero (machine epsilon). In such case, the program increases the tolerance to avoid an infinite loop. Otherwise, if the error is MUCH smaller than the tolerance the step is augmented to optimize the program and reduce the number of points of the solution. HINT: when the program asks for the number of steps I recommend entering (1), the program will divide the number of steps into the necessary number of points to meet the entered error tolerance. You can also enter (100000), the program reduces the number of steps as well. However, you will find that the final number of steps in both cases is a little different because the program leaves a safety marge when reducing a step.

How to use my program, create a directory with :

  • main.c
  • user_interface.h
  • makefile
  • files (create an empty folder)

Then run this directory on terminal and enter "make RK", then run the program by the command "./RK" (without the quotation marks of course!). You can simply compile and execute "main.c" but you need "-lm" to compile it for the "math.h" module.

Si vous comprenez le français, je peux vous envoyer le rapport en format PDF où j'ai bien expliqué le contrôle du pas (adaptive step-size) mathématiquement. J'ai eu la flemme de traduire le rapport en anglais...

I hope my code meets your needs. Enjoy!

runge-kutta's People

Contributors

rand-asswad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.