hit counter script

Formula Runge Kutta Order 1 The 1 Steps Needed For Putting Formula Runge Kutta Order 1 Into Action

Greetings all,

formula runge kutta order 2

7.1 | formula runge kutta order 2

I accept accounting the afterward cipher to account the band-aid to a arrangement of ODEs, alleged the Matsuoka equations, by application the Runge-Kutta 4th adjustment method. I am aggravating to apparatus this cipher on an Arduino microcontroller. The achievement of the equations, IC[0] – IC[2], should oscillate but instead it “blows up (down)” and goes to abrogating infinity. This is accounting for Arduino so some things may charge to be afflicted to get it to assignment in a authentic c or c environment.

First I set up 5 arrays: 1 copy arrangement and 4 arrays to authority the ethics of the K1,K2,K3, and K4 coefficients. The Runge Kutta algorithm is set up as a function. The affairs calls the action and passes the copy K arrangement by advertence to the function. The K arrangement is adapted due to the action calculations and again those ethics are stored in the K1 arrangement to be acclimated after to account the abutting footfall of the ODE. This action is again 3 times for the K2,K3, and K4 arrays. Finally the abutting footfall of the band-aid to the ODE is apparent application K1,K2,K3, and K4.

My botheration is fabricated curiouser by the actuality that I accept gotten the cipher to assignment by above all the for loops and analytic anniversary K accessory line-by-line. This cipher is displayed beneath the NON-WORKING CODE and is termed WORKING CODE. What’s absorbing actuality is that the two codes aftermath the aforementioned ethics for the K1 and K2 arrays but for the K3 arrangement the ethics alter in the K3[4] arrangement position. The alive cipher calculates K3[4] = 0.5 (which I accepted by calculation) while the non-working cipher calculates K3[4] = 0.49999995230. Why does it round?

Any advice as to why the NON-WORKING CODE assault up while the WORKING CODE oscillates would be abundantly apperciated.


void bureaucracy () {Serial.begin(9600);}

float c = 1, B = 2.5, Y = 2.5, tau1 = 1, tau2 = 2*tau1, timestep = 0.1, M = 0.5*timestep;float IC[] = {1,1,1,0}, K[] = {0,0,0,0}, K1[3], K2[3], K3[3], K4[3];int i;

void loop() {

rungeKutta(tau1,tau2,c,B,Y,0,IC[0],IC[1],IC[2],IC[3],K); //note M has been replaced by zerofor(i=0;i<=3;i )K1 = K;

rungeKutta(tau1,tau2,c,B,Y,M,IC[0],IC[1],IC[2],IC[3],K);for(i=0;i<=3;i )K2 = K;

rungeKutta(tau1,tau2,c,B,Y,M,IC[0],IC[1],IC[2],IC[3],K);for(i=0;i<=3;i )K3 = K;

rungeKutta(tau1,tau2,c,B,Y,timestep,IC[0],IC[1],IC[2],IC[3],K); //note M has been replaced by timestepfor(i=0;i<=3;i )K4 = K;

for(i=0;i<=3;i )IC = IC (1.0/6.0)*(K1 2.0*(K2 K3) K4)*timestep;

Serial.println(IC[0] – IC[2],DEC);

}//end capital loop

float rungeKutta(float tau1, float tau2, float c, float B, float Y, float M, float IC0, float IC1, float IC2, float IC3, bifold *K){K[0] = (1.0/tau1)*(c – (IC0 M*K[0]) – B*(IC1 M*K[0]) – Y*max(IC2 M*K[0],0));K[1] = (1.0/tau2)*(max(IC0 M*K[1],0) – IC1 M*K[1]);K[2] = (1.0/tau1)*(c – (IC2 M*K[2]) – (B*IC3 M*K[2]) – Y*max(IC0 M*K[2],0));K[3] = (1.0/tau2)*(max(IC2 M*K[3],0) – (IC3 M*K[3]));}//end of rungeKutta function


void bureaucracy () {



float c = 1, B = 2.5, Y = 2.5, tau1 = 1, tau2 = 2*tau1, timestep = 0.1, M = 0.5*timestep;;float IC[] = {1,1,1,0}, K1[3], K2[3], K3[3], K4[3];

void loop() {

K1[0] = (1.0/tau1)*(c – IC[0] – B*IC[1] – Y*max(IC[2],0));K1[1] = (1.0/tau2)*(max(IC[0],0) – IC[1]);K1[2] = (1.0/tau1)*(c – IC[2] – B*IC[3] – Y*max(IC[0],0));K1[3] = (1.0/tau2)*(max(IC[2],0) – IC[3]);

K2[0] = (1.0/tau1)*(c – (IC[0] M*K1[0]) – B*(IC[1] M*K1[0]) – Y*max(IC[2] M*K1[0],0));K2[1] = (1.0/tau2)*(max(IC[0] M*K1[1],0) – IC[1] M*K1[1]);K2[2] = (1.0/tau1)*(c – (IC[2] M*K1[2]) – (B*IC[3] M*K1[2]) – Y*max(IC[0] M*K1[2],0));K2[3] = (1.0/tau2)*(max(IC[2] M*K1[3],0) – (IC[3] M*K1[3]));

K3[0] = (1.0/tau1)*(c – (IC[0] M*K2[0]) – B*(IC[1] M*K2[0]) – Y*max(IC[2] M*K2[0],0));K3[1] = (1.0/tau2)*(max(IC[0] M*K2[1],0) – IC[1] M*K2[1]);K3[2] = (1.0/tau1)*(c – (IC[2] M*K2[2]) – (B*IC[3] M*K2[2]) – Y*max(IC[0] M*K2[2],0));K3[3] = (1.0/tau2)*(max(IC[2] M*K2[3],0) – (IC[3] M*K2[3]));

K4[0] = (1.0/tau1)*(c – (IC[0] timestep*K3[0]) – B*(IC[1] timestep*K3[0]) – Y*max(IC[2] timestep*K3[0],0));K4[1] = (1.0/tau2)*(max(IC[0] timestep*K3[1],0) – IC[1] timestep*K3[1]);K4[2] = (1.0/tau1)*(c – (IC[2] timestep*K3[2]) – (B*IC[3] timestep*K3[2]) – Y*max(IC[0] timestep*K3[2],0));K4[3] = (1.0/tau2)*(max(IC[2] timestep*K3[3],0) – (IC[3] timestep*K3[3]));

IC[0] = IC[0] (1.0/6.0)*(K1[0] 2.0*K2[0] 2.0*K3[0] K4[0])*timestep;IC[1] = IC[1] (1.0/6.0)*(K1[1] 2.0*K2[1] 2.0*K3[1] K4[1])*timestep;IC[2] = IC[2] (1.0/6.0)*(K1[2] 2.0*K2[2] 2.0*K3[2] K4[2])*timestep;IC[3] = IC[3] (1.0/6.0)*(K1[3] 2.0*K2[3] 2.0*K3[3] K4[3])*timestep;

Serial.println(IC[0] – IC[2],DEC);

}//end capital loop

Formula Runge Kutta Order 1 The 1 Steps Needed For Putting Formula Runge Kutta Order 1 Into Action – formula runge kutta order 2
| Delightful for you to my blog site, with this occasion I will provide you with with regards to keyword. And after this, this is the primary image: