# Numerical solution using runge kutta with programming in c++

0 %
100 %
Information about Numerical solution using runge kutta with programming in c++
Education

Published on March 4, 2014

Author: vjchere

Source: slideshare.net

## Description

Numerical Solution using Runge Kutta Method by the help of Programming in C++

Vijay Choudhary vijaycttf@gmail.com Department of Civil Engineering Poornima University, Jaipur

        Introduction Formulation of the problem Solution of the problem Approximations, errors Graphical representation Conclusion References Further Scope

A physical problem of finding how much concentration of the pollutant would be there in a lake after certain time. To find the concentration of the bacteria (pollutant), the problem is modeled as an ordinary differential equation. Runge Kutta 4th order method is used. Solutions obtained are compared with exact solutions and are graphically discussed and analyzed.

A polluted lake has an initial concentration of a bacteria of 107 parts/m3 , while the acceptable level is only 5*106 parts/m3 . The concentration of the bacteria will reduce as fresh water enters the lake. Find the concentration of the pollutant after 7 weeks. dC + 0.06C = 0 dt

The differential equation that governs the concentration C of the pollutant as a function of time (in weeks) is given by dC + 0.06 C = 0 ,C ( 0 ) =10 6 dt We Use the Runge-Kutta 4th order method and take a step size of 3.5 weeks.

#include<conio.h> #include<iostream.h> void main() { float c[10],f,t[10],h,n; cout<<"enter the initial values of concentration of bacteria "; int i; cin>>c[0]; cout<<"enter the initial value of time ";cin>>t[0]; cout<<"enter the value of time in weeks at which we want to see the concentration ";cin>>f; cout<<"enter the difference ";cin>>h; n= (f-c[0])/h;

for(i=1;i<=n;i++) { a=0 k1=-(.06*c[a]); k2=-h*(.06*(c[a]+k1/2)); k3=-h*(.06*(c[a]+k2/2)); k4=-h*(.06*(c[a]+k3)); k=(k1+2*k2+2*k3+k4)/6; y[i]=y[a]+1; a++; } Cout<<“n Table"; for(i=0;i<n;i++) { cout<<"t x=%fty=%f",val[i][0],val[i][1]); cout<<"n"); getch(); }

1

2

Figure 1 compare the exact solution with the numerical solution using Runge kutte 4th order method using different step size. It is observed that there is significant error when the calculation is done using Runge Kutte 4th order method with step size 7. This error can be minimized if we reduce the step size from 7 to 3.5. Now the numerical solution is close to the exact solution. Further reduction of step size from 3.5 to 1.75 does not bring any major error reduction. In Figure 2, we are comparing the exact results with Runge Kutte 1st order method (Euler), Runge Kutte 2nd order method( Heun) and the Runge Kutte 4th order method. It is observed that 4th order method give close approximation to exact solution than Heun’s method and Euler’s method

Book Numerical Solutions using Programming in C++, Volume I, Mittal Publication Chapter/Papers AP Azai , ., Graph Behaviour, Sindh College Of Engineering, Sindh (*paper) 64 Pages Internet James Amtoel , Contouring and Its Applications[online] http://www.civilogyusa.gov document [21/02/2014]. http://civilsimplified.com http://www.bournemouth.ac.uk/library/using/numerical-equations.html [Accessed 4 Feb 2014].

   By the help of C++ program, it would be easy to analysis results on different cases like step size, initial conditions, boundary values, type of method etc. Like application of 1st order differential equations in Radioactive science, we can use 2nd order differential equation in practical applications. We can mould problems of Density, Population, Traffics etc into 2nd order differential equations and can study the behavior of result via graph on different inputs.

  Program 1 Program 2

 User name: Comment:

## Related presentations

#### ACC 421 Teaching Effectively--tutorialrank.com

November 20, 2018

#### ACC 422 Teaching Effectively--tutorialrank.com

November 20, 2018

#### CIS510 Inspiring Innovation--snaptutorial.com

November 20, 2018

#### CIS512 Inspiring Innovation--snaptutorial.com

November 20, 2018

#### CIS515 Inspiring Innovation--snaptutorial.com

November 20, 2018

#### CIS517 Inspiring Innovation--snaptutorial.com

November 20, 2018

## Related pages

### RUNGE-KUTTA 4th ORDER METHOD - C Programming Examples and ...

... Example for RUNGE-KUTTA 4th ORDER METHOD in C Programming. ... » C Programming » Numerical ... value of a given function using Runge-Kutta ...

### Numerical solution using runge kutta with programming in ...

Numerical Solution using Runge Kutta Method by the help of Programming in C++

### Runge–Kutta methods - Wikipedia

These methods were developed around 1900 by the German mathematicians C. Runge and M. W. Kutta. ... The numerical solution to ... using implicit Runge ...

### Numerical programming in C - University of Leicester

Numerical programming in C ... further information look at the excellent Numerical Recipes in C by ... One solution is to break up the range of the ...

### RUNGE-KUTTA METHOD - C Programming Examples and Tutorials

Code for RUNGE-KUTTA METHOD in C Programming ... Program to estimate the Differential value of a given function using Runge-Kutta Methods; ... Numerical ...

### Numerical Programming 2 CSE - M2/Allgemeines

Numerical Programming 2 CSE ... Compute a numerical solution for the problem parameters ... Runge-Kutta and Multistep Methods, page 5 c)By de ning y(t) = x ...

### Runge-Kutta method - Rosetta Code

NB.*rk4 a Solve function using Runge-Kutta method NB. y is: y ... runge_kutta(f); ... {t, 0, 10}] (* Numerical solution II (RK4) *) f[{t_, y_}] := {1, ...