0% found this document useful (0 votes)
6 views4 pages

Runge Euler

runge kutte and euler algorithum program

Uploaded by

Paras Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Runge Euler

runge kutte and euler algorithum program

Uploaded by

Paras Agarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
1 #include 2 #define f(x,y) (y*y-x*x)/(y*y+x"x), 3 using namespace std; 4 int main() 5 ¢ 6 | float xe, ye, xn, h, yn, k1, k2, k3, ka, k3 7 int i, n3 8 — cout<<"Enter Initial Condition"<< endl; 9 cout<<"xo 10 cin>> x3 14, cout<<"yo = "5 12 cin >> yo; 13 cout<<"Enter calculation point xn = 14 cin>>xn; 15 cout<<"Enter number of steps: "5 16 cin>> n3 17h = (xn-xe)/ns 18 | cout<<"\nxo\tya\tyn\n"5 19 cout<<" 20 | for(i=o3 i < n3 i++) 22 { 22 ka * (F(x®, ye))3 23 k2 * (F((xoth/2), (york1/2)))5 24 k3 * (F((x@+th/2), (yOrk2/2)))5 25 ka * (FC(x@+h), (yOrk3)))5 26 k = (k1+2"k2+2"k3+k4)/65 27 yn = yo + k3 28 cout<< xO<<"\E"<< yox<"\t"<< ync< endl; 29 x@ = xO+h; 30 ye = yn; 3a, ¥ 32 cout<<"\nvalue of y at x = "<< xn<< "is " << yn; 33 return 03 34 + PS_D:\programming\hello world> cd “d:\programming\hello world\" Enter Initial Condition xO = 2 yo = 2 Enter calculation point xn = 5 Enter number of steps: 5 yn 2.34105 8 2.34105 2.4141 16 2.4141 2.22347 4 2.22347 1.78126 2 1.78126 1.13499 value of y at x = 5 is 1.13499 1 #include 2 #define f(x,y) (x-y)/(2) 3 using namespace std; 4 int main() 5 { 6 float xe, yo, xn, h, yn, ki, k2, k3, ka, k; 7 int i, n3 8 cout<<"Enter Initial Condition"<< endl; ° cout<<"xo = " 10 cin>> x05 a4 cout<<"ye = * 12 cin >> yo3 13 cout<<"Enter calculation point xn = 14 cin>>xn5 as cout<<"eEnter number of steps: 16 cin>> n3 17 h = (xn-xe)/n; 18 cout<<"\nxe\tye\tyn\n"5 19 cout<< ---- 3 20 for(i=03 i < m3 i++) 2a £ 22 ki = h * (F(x®, yo))s 23 k2 = h * (F((x@+h/2), (york1/2)))5 24 k3 = h * (F((x@+h/2), (york2/2)))5 25 ka = h * (F((xOth), (yOrk3)))5 26 k = (k1+2*k2+2*k3+k4)/63 27 yn = yO + k; 28 cout<< xo<<"\t"<< yoc<"\t"<< yn<< endl; 29 x® = xO+h; 30 ye = yn; 3a } 32 cout<<"\nvalue of y at x << xn<< “is " << yn; 33 return 93 34a} Enter Initial Condition - xo = 0 yo=a Enter calculation point xn = 2 Enter number of steps: 10 yn ©.914513 ° 2.2 ©.914513 0.856193 2.4 2.856193 0.822455 e.6 1822455 9.810961 o.8 @.810961 9.819593 x 2.819593 2.846436 ie 12846436 0.889757 ala 0.889757 01047988 ae @.9a70988 1.01971 ale 1101971 1.10364 Value of y at x = 2 is 1.10364 _ #include fdefine f(x,y) x+y using namespace std; int main() { float xe, yo, xn, h, yn, slopes inti, n cout<<"Enter Initial Condition"<< endl; cout<<"x@ cin>> xe; cout<<"yo cin >> yo; . cout<<"Enter calculation point xn = "5 cin>>xn3 cout<<"Enter number of steps: cin>> n3 h = (xn-x0)/n3 cout<<"\nx@\tye@\tslope\tyn\n cout<<" for(i=0; i < ns itt) { slope = f(x®, yo); yn = yo + h * slope; --\n"5 cout<< xO<<"\i" cd “d:\pri Enter Initial Condition xe eo yo=a Enter calculation point xn = 1 Enter number of steps: 5 xo yo slope = yn ] at a 1.2 e.2 1.2 1.4 1.48 e.4 1.48 1.88 1.856 2.6 1.856 2.456 2.3472 e.8 2.3472 3.1472 2.97664 value of y at x = 1 is 2.97664 #include #define f(x,y) x-y using namespace std; int main() A) float x®, ye, xn, h, yn, slope; int i, n3 cout<<"Enter Initial Condition"<< endl; cout<<"x@ = cin>> xo; cout<<"yo = cin >> yo; cout<<"Enter calculation point xn = cin>>xn3 cout<<"Enter number of steps: cin>> n; h = (xn-xe)/n; cout<<"\nx@\tya\tslope\tyn\n"5 for(i=03; i cd " Enter Initial condition "<< xnc< "is " << yn3 Enter calculation point xn = 0.5 Enter number of steps: 5 xo ye slope yn e a -1 0.9 e.1 2.9 -0.8 2.82 e.2 2.82 [email protected] 0.758 2.3 @.758 [email protected] 0.7122 0.4 @.7122 -0.3122 0.68098 Value of y at x = 0.5 is 0.68098

You might also like