zhanghouxing的个人博客分享 http://blog.sciencenet.cn/u/zhanghouxing

博文

截断误差与舍入误差

已有 33963 次阅读 2016-8-15 11:34 |个人分类:数学|系统分类:科研笔记|关键词:学者| 差分

(1)在数学中,有限差分方法(Finite Differenc Methods,FDM),是一种微分方程的数值方法,是通过有限差分来近似导数或者偏导数,从而求得微分方法的近似解。在实际中,许多数学问题都很难得到其解析解,所谓解析解就是可以通过给出解的具体函数形式,从解的表达式中就可以算出任何自变量对应值;而数值解是在特定条件下通过近似计算得出来的一个数值。

举个例子:

一般一元二次方程
a x^2 + b x + c == 0 (a ≠ 0)
的解析解为
x = (- b ±√(b^2 - 4 a c)) / (2 a)
数值解只能由具体的系数确定。


(2)导数的有限差分近似由泰勒展开的推算

假设f(x)在x0处各阶可导,则根据定理,其在x0+h的泰勒展开式为:

其中n!表示是n階乘Rn(x)為餘數,表示泰勒多項式和原函數之間的差。可以推導函數f一階導數的近似值:

设定x0=a,可得:

除以h可得:

求解f'(a):

R1(x)是x(x->a时)的高阶无穷小,假设R1(x)很小并可以忽略,可以将"f"的一阶导数近似为:

(一阶近似)


定理

n 是一个正整数。如果定义在一个包含 a区间上的函数 fa 点处 n+1 次可导,那么对于这个区间上的任意 x,都有:

[2]

其中的多项式称为函数在a 处的泰勒展开式,剩余的 是泰勒公式的余项,是 的高阶无穷小。

由于在近似过程中,我们截断了Rn(x),因此数值差方法本来存在误差,这种由于截断所引起的误差就是结尾误差。

差分的方法有不同分类,如前向,后向和中心差分:

前面两种是对偏微分方程一阶近似,中心差分式二阶近似。

差分还可以分为,explicit and implicit difference

显式方法

热传导方程最常用显式方法的模版

利用在时间的前向差分,以及在位置的二阶中央差分(FTCS 格式),可以得到以下的迭代方程:

这是用求解一维导热传导方程的显式方法

可以用以下的式子求解

其中

因此配合此迭代关系式,已知在时间n的数值,可以求得在时间n+1的数值。的数值可以用边界条件代入,在此例中为0。

此显式方法在时,为数值稳定收敛[1]。其数值误差和时间间隔成正比,和位置间隔的平方成正比:

隐式方法

隐式方法的模版

若使用时间的后向差分,及位置的二阶中央差分(BTCS 格式),可以得到以下的迭代方程:

这是用求解一维导热传导方程的隐式方法

在求解线性联立方程后可以得到

此方法不论的大小,都数值稳定且收敛,但在计算量会较显式方法要大,因为每前进一个时间间隔,就需要求解一个联立的数值方程组。其数值误差和时间间隔成正比,和位置间隔的平方成正比:


(3) 舍入误差是由于计算机数字限制(四舍五入)引起的

由于计算机的字长有限,进行数值计算的过程中,对计算得到的中间结果数据要使用“四舍五入”或其他规则取近似值,因而使计算过程有误差。这种误差称为舍入误差。在python中输入0.1+0.2,得到的结果是0.30000000000000004,这是舍入误差带来的结果。


There  are  two  approximations  in  numerical  modelling.  One  needs
to  ask  the  questions:  "How  well  is  the  natural  system  modelled  by  the
differential  equations?",  and,  "How  well  is  the  solution  to  the  differential
equations  represented  by  the  computational  algorithm?".  I n   the  analysis
here  more  attention  is  paid  to  the  second  question.  The  first  question
can  only  be  answered  by  studying  the  behaviour  of  the  natural  system
and  comparing  i t   to  the  equations  applied  to  it.  Therefore  i t   will  be
assumed  here  that  the  differential  equations  approximate  the  system  we1 I
despite  the  fact  that  i t   has  been  noticed  that  this  is  not  necessarily
the  case.  Abbott  (1974)  noticed  that  a  difference  scheme  considerably
different  from  the  differential  equations  used  to  describe  a  system,  can
yield  more  accurate  results  than  a  difference  scheme  similar  to  the
differential  equations  when  compared  with  experimental  results.
There  are  three  possible  sources  of  error  associated  with  finite
difference  solutions  to  partial  differential  equations.  I t   is  important
that  one  understands  these  sources,  their  consequence  if  not  control led,
and  means  for  controlling  them.  These  three  sources  of  error  are:
truncation,  discretization,  and  round-off.  Truncation  error  occurs  when
a  derivative  is  replaced  with  a  finite  difference  quotient;  discretization
error  is  due  to  the  replacement  of  a  continuous  model  (function)  with
a  discrete  model;  and  round-off  error  is  essentially  machine  error  in
that  the  algebraic  finite  difference  equations  are  not  always  solved
exactly .

For  finite  difference  solutions  to  be  accurate,  they  must  be  con-
sistent  and  stable.  Consistency  simply  means  that  the  truncation  errors
tend  to  zero  as  Ax  and  At  -  >  0,  i.e.,  as  Ax  and  At  - >  0  the  finite
difference  equation  becomes  the  original  differential  equation.  This  is
examined  i n   the  follcwing  paragraphs.  Stability  implies  the  controlled
growth  of  round-off  error.  Stability  considerations  apply  principally  to
explicit  schemes  to  be  discussed  later.  Any  numerical  scheme  that  allows
the  growth  of  error,  eventually  "swamping"  the  true  solution,  is  unstable.


References

(1) https://zh.wikipedia.org/zh-cn/%E6%9C%89%E9%99%90%E5%B7%AE%E5%88%86%E6%B3%95

(2) https://zh.wikipedia.org/wiki/%E6%B3%B0%E5%8B%92%E5%85%AC%E5%BC%8F

(3) Stephenson, D., kinematic hydrology and modelling. 1986.

(4) Chow, E.A., Applied hydrology. 1988.



https://m.sciencenet.cn/blog-922140-996550.html

上一篇:显式与隐式差分
下一篇:C语言字符处理

1 zjzhaokeqin

该博文允许注册用户评论 请点击登录 评论 (1 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-2 19:04

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部