EDA365电子论坛网

标题: 介绍一下Matlab的浮点相对精度eps [打印本页]

作者: mytomorrow    时间: 2019-12-18 11:10
标题: 介绍一下Matlab的浮点相对精度eps
, C5 X3 z) h( f# R5 r6 J+ Y9 N
目录
+ n" }, K5 F4 h# w
/ k5 o! o+ ]+ j: \% s
8 F9 e# l& |$ @9 J: Z, \eps$ }) \. E1 V8 a9 C9 u) h

9 J+ k5 o( u! Z' ]3 C7 M$ W       Syntax( [8 `$ L) [7 v+ m: f$ |: A
  e$ C5 D$ w6 T1 ]. v. Z
       Description
* [! a7 x4 C$ y" o; x+ U( W  Q. Z% D1 S7 X5 ?" Y- }/ c* b3 P
              Accuracy in Double Precision
' W: {) q9 c6 U- Z) K3 v$ F7 j- c& i, x, G. j
              Accuracy in Single Precision8 ?+ e/ o. ?: l3 a" R

" V# N2 c" ?0 Q7 ]. T$ x7 v8 z& K% z+ }
eps9 c* W" ?+ t0 J( Z0 s. t
Floating-point relative accuracy
. B( ]  H+ h2 y2 e$ Y: ^2 g7 ^* s- Y7 c8 s9 z
Syntax' {& T' f. p' D/ Y" j. _
d = eps
1 n5 g$ `2 w- a* w3 [" d3 P2 M* L3 @/ D3 b% n+ k
d = eps(x)
7 {; i( Z. j, M1 M
1 s+ I0 B( @$ e: sd = eps(datatype)- g- i! L8 j1 l3 q8 i. e. [6 ]
9 m; _9 j7 O( |% F$ X1 L% w- O0 E
Description1 N" O* s4 m! ^3 Y

. N. h( z- b. Ad = eps returns the distance from 1.0 to the next larger double-precision number, that is, .' r- \7 a5 h) m; Y" V0 T' S; z
% |) _9 ?; a! u- S# [5 y
d = eps返回从1.0到下一个更大的双精度数的距离,即。; T7 Z% p. k" @) Y, Z0 C
0 g. C1 t; L9 d) j
d = eps(x), where x has data type single or double, returns the positive distance from abs(x) to the next larger floating-point number of the same precision as x. If x has typeduration, then eps(x) returns the next larger duration value. The command eps(1.0) is equivalent to eps.
+ J' R( m- \2 Z3 R4 U3 V2 Z( z$ l# k; }
d = eps(x),其中x具有数据类型single或double,返回从abs(x)到下一个与x相同精度的较大浮点数的正距离。 如果x具有typeduration,则eps(x)返回下一个更大的持续时间值。 命令eps(1.0)等同于eps。& I  g* s; T; q4 k8 V1 Y
7 b8 q3 L! o  u* U+ f+ T
d = eps(datatype) returns eps according to the data type specified by datatype, which can be either 'double' or 'single'. The syntax eps('double') (default) is equivalent to eps, and eps('single') is equivalent to eps(single(1.0)).
# d9 h" q, R1 V( K/ U3 L' w& C( e, m! }" S
d = eps(datatype)根据datatype指定的数据类型返回eps,数据类型可以是“double”或“single”。 语法eps('double')(默认)等同于eps,eps('single')等同于eps(single(1.0))。
  A: l# a# ~/ c% h9 a6 C/ A: n+ `$ p8 K' }2 I. z2 o
+ T* V6 t3 r  T1 }! j
Accuracy in Double Precision
% ]  R: I+ ?1 M9 c) u# f2 V4 \2 H2 h$ M' C( E/ X

, |* m4 \8 Q% R" [+ |    6 s2 K- }3 V& {4 `4 T; a

0 Y9 X# d) v" E4 [- e结果如下:, b  C/ n$ u! _) {( Z: }

: S: u8 Q3 b, Z3 K4 k) sd =; k# S+ H' w7 r$ t: y. ^

- l$ N  I3 z) |, ^9 Q' {( c   2.2204e-162 ?9 Z/ V- V: ~

3 J: _3 u$ Z1 ~$ v% Ed =
) g- [; k( r) H0 q1 Z& m* e6 N4 z" G( n  V: B* |+ U- K
   -524 i0 L: B. v, Z0 P

& `( ]* J3 V5 K  p) {" ]6 P( d% Yd =
" H- F& A# B; I, |
. x( {- n' v& j% {   1.7764e-15
: o0 r3 Q+ x0 _9 w7 A9 f" _8 G
! L% h- e5 @  t8 p: d
& d2 S/ L4 d6 mAccuracy in Single Precision
" Q# T, K' H% A
! R* a4 n8 y% d     ' }3 D9 I# l7 t6 z
: f% o, q* n/ D- G  P7 T7 c2 Y
结果如下:& G  j" B) O, p

5 ]  U& @4 E8 I! U, F6 md =
, {6 W5 s. @1 A* ^) R
% s5 K0 f' p2 q6 e  single  X/ Z& T! |/ h, Z8 a- o2 S, b1 S8 m

: C% I) G  V# l, b  1.1921e-07
% n( a# Z- @3 y
+ ~- j: c2 @9 z8 @5 A3 N7 |5 r6 P% h2 ed =3 m% v1 p% [$ h) l# w% g& {/ q& ^
  @: c$ B2 z% f6 {% B5 q- S) Q: u
  single
- n: Y. v# H* v- Y- q: w2 \! t. f* h" b# t: T
   -23
: M' k" K, x7 b6 G
/ w! c9 q3 s- R2 @0 id =
5 I6 O8 K7 Y6 M  O& J$ @- z6 d/ y3 E
  single4 p! \" A) e* @- C* L+ C& P

6 r7 Z7 Q+ G/ O( o. ]% T$ E  9.5367e-07' X3 C" i2 `: g# g. p. p
2 F& t4 K% a! O1 q9 I

9 j$ T7 E; q( x2 T( Z% Q! Z+ D8 b% y6 o7 j" P+ }
( T1 \4 E. Y: X, x+ ~1 c+ |6 o: B

作者: xixihahaheihei    时间: 2019-12-18 17:38
谢谢分享




欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/) Powered by Discuz! X3.2