1、2022-12-2511.1 Errors and Significant Digits1.1.1 Truncation error and round off error Truncation error:made by numerical algorithms,arise from taking finite number of steps in computation Chapter 1Chapter 1 ErrorsErrors2022-12-252computation sin x,where40,x According to the expansion of sinAccordin
2、g to the expansion of sin x)!12()1(!7!5!3sin12753nxxxxxxnn(1.1)But we have to use its finite items to But we have to use its finite items to approximate sinx,for example,approximate sinx,for example,compute sin0.5,set compute sin0.5,set n=3,n=3,479625.0!75.0!55.0!35.05.05.0sin753Eg.1.1x is a radian,
3、not degree.2022-12-253 According to the Taylors remainder,According to the Taylors remainder,!9)1(99R4,0(1.2)791013.3362880)4/(RThis result is very accurate.This result is very accurate.2022-12-254Eg.1.2Taking only a few terms of a Maclaurin series toapproximate.!3!2132xxxexxeIf only 3 terms are use
4、d,!21 2xxeErrorTruncationx2022-12-255Eg.1.3(Secant line)Using a finite xto approximate)(xf xxfxxfxf)()()(PQsecant linetangent lineFigure 1.Approximate derivative using finite x2022-12-256Eg.1.4 (Differentiation)Find)3(f for 2)(xxfusingxxfxxfxf)()()(and2.0 x2.0)3()2.03()3(fff2.0)3()2.3(ff2.032.3222.0
5、924.102.024.12.6The actual value is,2)(xxf632)3(fTruncation error is then,2.02.66Can you find the truncation error with 1.0 x2022-12-257Eg.1.4(Integration)Use two rectangles of equal width to approximate the area under the curve for2)(xxfover the interval9,3932dxx2022-12-258Integration example(cont.
6、)69()()36()(6232932xxxxdxx3)6(3)3(2213510827Choosing a width of 3,we haveActual value is given by932dxx9333x23433933Truncation error is then99135234Can you find the truncation error with 4 rectangles?2022-12-25920.66666667 310.3333333333.1415926Round off error:using finite precision floating-point n
7、umbers on computers to represent real numbers 2022-12-25101.1.2 Absolute error and relative error Definition 1.1Definition 1.1 let let x x*be the accurate value be the accurate value(unknown),and x be an approximation to x(unknown),and x be an approximation to x*,then,then E E=x-x*is called the abso
8、lute error of xis called the absolute error of x*.In general,we cant get the absolute error In general,we cant get the absolute error because we do not know the true value of x,but we because we do not know the true value of x,but we can estimate the error with absolute error bound can estimate the
9、error with absolute error bound defined as follows:defined as follows:Definition 1.2 Definition 1.2 A positive number A positive number is called the is called the absolute error bound of xabsolute error bound of x*if if x*-x.2022-12-2511 Remark.In general,xIn general,x*is unknown,so we replace is u
10、nknown,so we replace x x*by x,by x,rEexCan you give the reason?Can you give the reason?Definition 1.3Definition 1.3 If x is an approximation to x If x is an approximation to x*,thenthen is called the relative error of x*.*rExxexx2022-12-2512Eg.1.5 Suppose x=9999,x*=10000,y=9,y*=10.Please show the ab
11、solute error and relative error of them.Solution.Ex=9999-10000=-1,Ey=9-10=-1.er(x)=(9999-10000)/10000=-0.0001.er(y)=(9-10)/10=-0.1.1.1.3 Significant Digits Defintion 1.4 Suppose is the approximation to x*.If then the number x is said to approximate x*to l significant digits.120.10mnxa aa|*|0.510mlxx
12、Machine representation of numbers 2022-12-2513Eg.1.6 Suppose x*=20.03173,and x1=20.03,x2=20.031,x3=20.032 are its approximations respectively.Determine the numbers of significant digits of them.Solution.Rewrite x1,x2 and x3 as x1=0.2003102,x2=0.20031102,x3=0.20032102.Since According to Definition 1.
13、4,x1,x2 and x3 have 4,4 and 5 significant digits respectively.241242253|*|0.001730.510,|*|0.000730.510,|*|0.000270.510,xxxxxx2022-12-2514 Sometimes,we cut a long number into a short Sometimes,we cut a long number into a short number through rounding.number through rounding.Eg.1.7 According to the ro
14、unding rule,write the following numbers with 5 significant digits.287.9325 287.9325 0.03785551 0.03785551 8.000033 8.000033 2.718281828459045 2.718281828459045 2.765450 2.765450 Solution.Solution.287.9325287.93(rounding down)287.9325287.93(rounding down)0.037855510.037856(rounding up)0.037855510.037
15、856(rounding up)8.0000338.0000 (rounding down)8.0000338.0000 (rounding down)2.7182818284590452.7183(rounding up)2.7182818284590452.7183(rounding up)2.7654502.7655(rounding up)2.7654502.7655(rounding up)2022-12-2515Theorem 1.1 Suppose with n significant digits,then the relative error bound of x*120.1
16、0mnxa aa 111102nraTheorem 1.2 If the relative error bound of120.10mnxa aa 111102(1)nraisthen x has at least n significant digits.2022-12-25161.2 Propagation of ErrorsWhen we use inaccurate numbers to calculate,how do these inaccuracies propagate through the calculations?2022-12-2517Eg.1.8Find the bo
17、unds for the propagation in adding two numbers.For example if one is calculating X+Y whereX=1.5 0.05Y=3.4 0.04SolutionMaximum possible value of X=1.55 and Y=3.44Maximum possible value of X+Y=1.55+3.44=4.99Minimum possible value of X=1.45 and Y=3.36.Minimum possible value of X+Y=1.45+3.36=4.81Hence 4
18、.81 X+Y 4.99.2022-12-2518Propagation of Errors In FormulasfnnXXXXX,.,1321fnnnnXXfXXfXXfXXff112211.If is a function of several variables then the maximum possible value of the error in is2022-12-2519Eg.1.9The strain in an axial member of a square cross-section is given byGivenFind the maximum possibl
19、e error in the measured strain.2Fh EN9.072Fmm1.04hGPa5.170E2022-12-252032972(4 10)(70 10)610286.64286.64FhEFhE Solution 2022-12-2521EhF21EhFh3222EhFEEEhFhEhFFEhE22322192923933923105.1)1070()104(720001.0)1070()104(7229.0)1070()104(13955.5ThusHence)3955.5286.64(2022-12-2522Eg.10Subtraction of numbers
20、that are nearly equal can create unwanted inaccuracies.Using the formula for error propagation,show that this is true.SolutionLetThenSo the relative change isyxzyyzxxzzyx)1()1(yxyxyxzz2022-12-2523Eg.11For example if001.02x001.0003.2y|003.22|001.0001.0zz=0.6667=66.67%2022-12-25241.3.1 Avoid the subtr
21、action of nearly equal numbers The subtraction of nearly equal numbers will loss significant digits largely,so this operation leads to a larger relative error.Eg.1.12 Compute the approximation to x*y*using 4-digits.x=18.496;=18.496;y=17.208=17.208 x=18.496;=18.496;y=18.493=18.493Solution.Solution.Th
22、e approximations with 4-digits toThe approximations with 4-digits to x*and y*using the Rounding Rule are as follows:x=18.50;y=17.21 x y=18.50 17.21=1.29In fact x*y*18.49617.2081.2883 How to Avoid the Loss of Accuracy2022-12-2525Absolute error Relative error|1.288 1.29|0.002E|1.288 1.29|0.16%|1.29|RE
23、 The approximations with 4-digits to The approximations with 4-digits to x*and y*using the Rounding Rule are as follows:x=18.50;y=18.49 x y=18.50 18.49=0.01 in fact x*y*18.49618.4930.003 Absolute error Relative error|0.0030.01|0.007E|0.0030.01|70%|0.01|RE2022-12-2526Find a better solution:more signi
24、ficant digits;more significant digits;using a using a better computation form,for examplebetter computation form,for example1.3.2 Avoid big numbers“swallowing”important small numbers12ln()lnln(1/)sin()sin2cos(/2)sin(/2)xhxhhxhxhxhxh xxhxxhhEg.1.1.13 To calculate 1-cos0.1 using two ways.(4 significan
25、t digit)1-cos0.1=1-0.9950=0.00502sin2(0.05)=2*0.04498*0.04498=0.004496.True value:0.004496.2022-12-2527Eputing roots of a quadratic equationUsing 4 digits rounding arithmetic,apply the formula 21,242bbacxa To the equation 2100010.xx Solution.In this equation,b2 is a much larger than 4ac,which induce
26、s 2277722410004.0000.1000 100.0000 100.1000 10.410004.0001000.bacbacWe have212241000 10000;22.00041000 10001000.22.000bbacxabbacxa 2022-12-2528But the accurate solution is 120.00100;999.998.xx We can find a very great error for x1.A better way is 212224220.001000.21000 1000441000 10001000.22.000bbaccxabbacbbacxa 2022-12-25292341(1)ln(1)234nnxxxxxxn1111(1)ln21234nn If set=10-5,we have to compute until n1052521ln2(1)13521nxxxxxxnLet x=1/3,result can satisfy the precision by only computing 5 times.Eg.1.151.3.3 Avoid a big Number Dividing by a small number1.3.4 Reducing computations
侵权处理QQ:3464097650--上传资料QQ:3464097650
【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。