110 likes | 275 Views
AME 150 L. Numerical Integration. Homework 10. Numerical Integration of sin(x) from 0 to p Trapezoidal Rule I I h =( h /2)( y 0 +2 y 1 +2 y 2 +. . .2 y n -2 +2 y n -1 + y n ) | error T | h 2 ( b-a ) max | y''( x ) |/12 Simpson's Rule I h /3( S ends +4 S odds +2 S evens )
E N D
AME 150 L Numerical Integration AME 150L
Homework 10 • Numerical Integration of sin(x) from 0 to p • Trapezoidal Rule IIh=(h/2)(y0+2y1+2y2+. . .2yn-2+2yn-1+yn) |errorT| h2(b-a) max |y''(x)|/12 • Simpson's Rule I h/3(Sends+4Sodds+2Sevens) |errorT| h4f iv(x)(b-a)/180 AME 150L
1 0.9 0.8 0.7 0.6 sin ( x ) ( ) p - x 0.5 × × 4 x 2 p 0.4 0.3 0.2 0.1 0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2 0 x AME 150L
Double Precision required AME 150L
Truncation Coefficients AME 150L
Truncation Coefficients AME 150L
Single Precision • Single precision (32-bit) floating-point numbers use 8 bits in the exponent and 23 bits in the fraction, which gives about 7 digit precision and allows storage of numbers whose magnitudes range from roughly 10-38 to about 1038. AME 150L
Double Precision • Double precision (64-bit) floating-point numbers use 11 bits in the exponent and 52 bits in the fraction, which gives about 15 digit precision and allows storage of numbers whose magnitudes range from roughly 10-308 to about 10308. AME 150L
Fortran Double Precision • REAL (Kind=8):: list of variable • Machine dependent (not if use IEEE floating point) • (Kind=4) is normal • Other Kinds • INTEGER has Kind=1, 2, and 4 • Logical has Kind=1, 4 AME 150L
More Double Precision • Specifying Double Precision Constants • lot of decimal digits or"d" in exponent 1.D0 (is double precision 1) or _"kind": 1.0_8 • Functions: • Selected_Real_Kind( p, r ) • Selected_Integer_Kind( r ) • Kind(x) - returns kind for x • Precision(x) - returns precision for x • Range(x) - returns decimal exponent range for x AME 150L