exam bonus
DESCRIPTION
Runge Kutta MethodTRANSCRIPT
-
EXAM BONUS
ES 204
Submitted by:
Timothy John S. Acosta
Submitted on:
April 22, 2015
-
Executive Summary: Adaptive Integration
A. Define the Problem
Integrate the function
100
2sin(
10
3
1
)
adaptively with a tolerance of 1x10-5
B. Problems Encountered
Working with multiple functions.
C. References
Gerald and Wheatley.(2004).Applied Numerical Analysis. 7th Ed. USA: Pearson
Education, Inc..
D. Results
Figure 1. Function plot with the intervals displayed
-80
-60
-40
-20
0
20
40
60
80
0 0.5 1 1.5 2 2.5 3 3.5
Integration from [1,3]
-
Interval Error Tolerance I
a b
1 1.00781 1.47E-08 3.91E-08 -0.3961
1.00781 1.01562 1.42E-08 3.91E-08 -0.33845
1.01562 1.02344 1.36E-08 3.91E-08 -0.28137
1.02344 1.03125 1.29E-08 3.91E-08 -0.2252
1.03125 1.03906 1.22E-08 3.91E-08 -0.17025
1.03906 1.04688 1.14E-08 3.91E-08 -0.11679
1.04688 1.05469 1.06E-08 3.91E-08 -0.06505
1.05469 1.0625 9.86E-09 3.91E-08 -0.01523
1.0625 1.07031 9.08E-09 3.91E-08 0.032519
1.07031 1.07812 8.32E-09 3.91E-08 0.078052
1.07812 1.08594 7.57E-09 3.91E-08 0.121267
1.08594 1.09375 6.86E-09 3.91E-08 0.162087
1.09375 1.10156 6.17E-09 3.91E-08 0.200454
1.10156 1.10938 5.52E-09 3.91E-08 0.236333
1.10938 1.11719 4.90E-09 3.91E-08 0.269709
1.11719 1.125 4.32E-09 3.91E-08 0.300583
1.125 1.13281 3.78E-09 3.91E-08 0.32897
1.13281 1.14062 3.27E-09 3.91E-08 0.3549
1.14062 1.14844 2.80E-09 3.91E-08 0.378414
1.14844 1.15625 2.37E-09 3.91E-08 0.399563
1.15625 1.17188 5.73E-08 7.81E-08 0.853416
1.17188 1.1875 3.61E-08 7.81E-08 0.91125
1.1875 1.20312 1.88E-08 7.81E-08 0.952718
1.20312 1.21875 4.95E-09 7.81E-08 0.979174
1.21875 1.23438 5.94E-09 7.81E-08 0.99203
1.23438 1.25 1.43E-08 7.81E-08 0.992716
1.25 1.26562 2.04E-08 7.81E-08 0.982647
1.26562 1.28125 2.48E-08 7.81E-08 0.963192
1.28125 1.29688 2.76E-08 7.81E-08 0.935661
1.29688 1.3125 2.93E-08 7.81E-08 0.901288
1.3125 1.32812 3.00E-08 7.81E-08 0.861223
1.32812 1.34375 2.99E-08 7.81E-08 0.816527
1.34375 1.35938 2.92E-08 7.81E-08 0.768167
1.35938 1.375 2.82E-08 7.81E-08 0.717022
1.375 1.39062 2.68E-08 7.81E-08 0.66388
1.39062 1.40625 2.52E-08 7.81E-08 0.609442
1.40625 1.42188 2.35E-08 7.81E-08 0.554327
1.42188 1.4375 2.17E-08 7.81E-08 0.499078
-
1.4375 1.45312 1.99E-08 7.81E-08 0.444164
1.45312 1.46875 1.81E-08 7.81E-08 0.38999
1.46875 1.48438 1.64E-08 7.81E-08 0.336897
1.48438 1.5 1.47E-08 7.81E-08 0.285172
1.5 1.51562 1.31E-08 7.81E-08 0.235052
1.51562 1.53125 1.17E-08 7.81E-08 0.186729
1.53125 1.54688 1.03E-08 7.81E-08 0.140353
1.54688 1.5625 9.02E-09 7.81E-08 0.096039
1.5625 1.57812 7.86E-09 7.81E-08 0.053871
1.57812 1.59375 6.80E-09 7.81E-08 0.013904
1.59375 1.60938 5.84E-09 7.81E-08 -0.02383
1.60938 1.625 4.97E-09 7.81E-08 -0.05932
1.625 1.65625 1.22E-07 1.56E-07 -0.21619
1.65625 1.6875 8.25E-08 1.56E-07 -0.33169
1.6875 1.71875 5.12E-08 1.56E-07 -0.43039
1.71875 1.75 2.72E-08 1.56E-07 -0.51326
1.75 1.8125 6.73E-08 3.13E-07 -1.21766
1.8125 1.84375 1.36E-08 1.56E-07 -0.67879
1.84375 1.875 2.00E-08 1.56E-07 -0.71046
1.875 1.90625 2.41E-08 1.56E-07 -0.73243
1.90625 1.9375 2.64E-08 1.56E-07 -0.74585
1.9375 1.96875 2.74E-08 1.56E-07 -0.75182
1.96875 2 2.74E-08 1.56E-07 -0.75132
2 2.03125 2.68E-08 1.56E-07 -0.7453
2.03125 2.0625 2.56E-08 1.56E-07 -0.73457
2.0625 2.09375 2.41E-08 1.56E-07 -0.71989
2.09375 2.125 2.25E-08 1.56E-07 -0.70194
2.125 2.15625 2.08E-08 1.56E-07 -0.68132
2.15625 2.1875 1.90E-08 1.56E-07 -0.65856
2.1875 2.21875 1.73E-08 1.56E-07 -0.63413
2.21875 2.25 1.56E-08 1.56E-07 -0.60843
2.25 2.28125 1.40E-08 1.56E-07 -0.58184
2.28125 2.3125 1.25E-08 1.56E-07 -0.55464
2.3125 2.34375 1.11E-08 1.56E-07 -0.52712
2.34375 2.375 9.87E-09 1.56E-07 -0.4995
2.375 2.4375 2.62E-07 3.13E-07 -0.91665
2.4375 2.5 2.01E-07 3.13E-07 -0.8092
2.5 2.5625 1.52E-07 3.13E-07 -0.70609
2.5625 2.625 1.13E-07 3.13E-07 -0.60852
2.625 2.6875 8.30E-08 3.13E-07 -0.51721
2.6875 2.75 5.94E-08 3.13E-07 -0.43252
-
2.75 2.8125 4.12E-08 3.13E-07 -0.35457
2.8125 2.875 2.75E-08 3.13E-07 -0.28327
2.875 3 4.18E-07 6.25E-07 -0.37814
Table 1. Intervals with corresponding integration
The integration over the domain using adaptive integration gave a value of -1.42603.
Appendix 1. List of Programs
double adaptintegration(double a,double b,double c,double x,double xT,double tol,double beg,double endd){ double simpsteps(double a,double b, double &c,double &x,double &xT,double &xa); double error,h=(b-a)/2; double xa=0; ofstream filer; filer.open("data.txt",ios_base::app); cout
-
double simps(double z,double y); double rxtrap(double k,double MA,double LA); double evaluate(double v); double x1,x2; //Large Interval xa=simps(a,b); //Bisection Interval c=a+(b-a)/2; x1=simps(a,c); x2=simps(c,b); xT=x1+x2; x=rxtrap(1,xT,xa); } double simps(double a,double b){ double evaluate(double z); double ans=0; double h=(b-a)/2; double c=a+h; a=evaluate(a); b=evaluate(b); c=evaluate(c); ans=h/3*(a+4*c+b); return ans; } double rxtrap(double k,double MA,double LA){ double ans; ans=(pow(4,k)*MA-LA)/(pow(4,k)-1); return ans; } double evaluate(double a){ double x; x=100/(a*a)*sin(10/a); return x; } int main() { double beg=1,endd=3; double x=0,xT=0; double error,a,b,c; double tol=1e-5;
- //Initial Conds a=beg; b=endd; ans=adaptintegration(a,b,c,x,xT,tol,beg,endd); cout