2012-10-01T08:15:03-04:00
Solve the coupled differential equations using Rutta-Kutta method.
dx/dt=(x/tc)*((y/Nt)-1)
dy/dt=(-2x/tc)(y/Nt)
Where
initial y = 10e19
initial x =1
Nt = 10e18
nr = 1.5
D = 0.1
c = 3*10e8
tc = 2D/(0.1(c/nr))
1
2012-10-02T10:25:06-0400
#include<iostream> #include<iomanip> #include <math.h> using namespace std; double f(double x,double y) {return (y-(pow(10.0,18))/2*y);} int main() {double h=0.1; double y[11],x[11]; int k; k=pow(10.0,19); y[0]=k; for(int i=0; i<11;i++){x[i]=i*h;} for(int i=0; i<11;i++) {y[i+1]=y[i]+h*( f(x[i],y[i]) + 2*f((x[i]+h/2),(y[i]+f(x[i],y[i])/2)) + 2*f((x[i]+h/2),(y[i]+f((x[i]+h/2),(y[i]+f(x[i],y[i])/2))/2)) + f((x[i]+h),(y[i]+f((x[i]+h/2),(y[i]+f((x[i]+h/2),(y[i]+f(x[i],y[i])/2))/2)))))/6;} for(int i=0; i<11;i++){cout<<setw(50)<<x[i]<<setw(50)<<y[i]<<endl;} double l=0; cin>>l; return 0;}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments