由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Computation版 - let me ask a question again
相关主题
老大们再帮一把吧是不是cygwin问题?
问个专业问题,请帮助看看在matlab中,如何提高ode45的求解速度呢?
maple ODE 方程组求解问题高手教教怎么在fortran里头call c++的function阿?
[help]should I switch from Matlab to C?!!! How to adjust precision in CPLEX !!!
谁有数值解两个(2D)Ito SDE的经验啊?Python下面如何进行numeric analysis and statistical analysis (转载)
推荐numerical解ODE方面的书请教一个numerical analysis的题目
累计误差怎么怎 么 这 么 大 ?Analytic solution for an ODE
simulation of a set of stochastic ODE计算! 计算!
相关话题的讨论汇总
话题: double话题: eps话题: precision话题: 1e话题: numerical
进入Computation版参与讨论
1 (共1页)
K*****N
发帖数: 117
1
who knows if C has "long double" type?
在numerical计算的时候通常会set up一个精度EPS,这个值和你定义的type有什么
关系。 比如,我的type都是double, 如果EPS=1.0e-10,会有什么问题么?
h***o
发帖数: 539
2
有.....ld = 3.1415926L;
double should be enough to handle EPS=1.e-10
you can also try this.
double a, b;
a = b = 3.0;
a += 1.e-10;
if (a == b)
printf("try long double");
else
printf("double is enough");

【在 K*****N 的大作中提到】
: who knows if C has "long double" type?
: 在numerical计算的时候通常会set up一个精度EPS,这个值和你定义的type有什么
: 关系。 比如,我的type都是double, 如果EPS=1.0e-10,会有什么问题么?

b*****y
发帖数: 163
3
C has long double, but may not be implemented by particular compiler,
since there is little numerical advantage to do long double rather
than just double precision. In double precision, eps = 1e-16 which
is enough to handle your 1e-10. For single precision, eps = 1e-07.
Most numerical computation is carried under either single or double
precision, which are IEEE standard, using 32 or 64 bits coding and very
easy to handle with modern computer architecture. One can
achieve arbitrary eps such as 1

【在 K*****N 的大作中提到】
: who knows if C has "long double" type?
: 在numerical计算的时候通常会set up一个精度EPS,这个值和你定义的type有什么
: 关系。 比如,我的type都是double, 如果EPS=1.0e-10,会有什么问题么?

K*****N
发帖数: 117
4
thanks. yes. from numerical recipe, i read some info. about double and
float. for double, it's up to 10e-15 and for float, it's up to 3.0e-8.
it makes sense to me.
however, if you would, please take a look at
page 717 in http://www.library.cornell.edu/nr/bookcpdf/c16-2.pdf.
i am still confused about what epsion value it could be. In the book, it says
"the number like 10e-6 or whatever...." i am very confused about what does
"whatever" mean.
best wishes,
Wilson

【在 b*****y 的大作中提到】
: C has long double, but may not be implemented by particular compiler,
: since there is little numerical advantage to do long double rather
: than just double precision. In double precision, eps = 1e-16 which
: is enough to handle your 1e-10. For single precision, eps = 1e-07.
: Most numerical computation is carried under either single or double
: precision, which are IEEE standard, using 32 or 64 bits coding and very
: easy to handle with modern computer architecture. One can
: achieve arbitrary eps such as 1

h***o
发帖数: 539
5
1.e-6 is from the example mentioned above, "get a solution good to
one part of in 1e+6" (1 ppm)
The basic idea in that part is to initiate the discussion of
choosing good scale values.
You are solving ODE with initial values?

【在 K*****N 的大作中提到】
: thanks. yes. from numerical recipe, i read some info. about double and
: float. for double, it's up to 10e-15 and for float, it's up to 3.0e-8.
: it makes sense to me.
: however, if you would, please take a look at
: page 717 in http://www.library.cornell.edu/nr/bookcpdf/c16-2.pdf.
: i am still confused about what epsion value it could be. In the book, it says
: "the number like 10e-6 or whatever...." i am very confused about what does
: "whatever" mean.
: best wishes,
: Wilson

h***o
发帖数: 539
6
btw...you can also test if 'double' is enough for your ESP
as long as you know the scale values for your problem.
basically, a good numerical routine/function should be able to
notice the underflow problem. for example page 714 of NR in C
"if ((float)(x+h) == x) nrerror("step size too small in routine rkdmb");"

【在 h***o 的大作中提到】
: 1.e-6 is from the example mentioned above, "get a solution good to
: one part of in 1e+6" (1 ppm)
: The basic idea in that part is to initiate the discussion of
: choosing good scale values.
: You are solving ODE with initial values?

b*****y
发帖数: 163
7

They talked about solving a system of ODEs which consists of state variables
with different magnitudes. If you want to solve the system with one tolerance,
you have to make sure every equation achieve that accuracy. 10e-06 means
the tolerance (eps here). The scaling part comes in because some state
variables may not need such a high accuracy as 1e-06, so you use scaling
vector to make the magnitudes of state variables close to each other.
To clarify the terminology, in double precision under IE

【在 K*****N 的大作中提到】
: thanks. yes. from numerical recipe, i read some info. about double and
: float. for double, it's up to 10e-15 and for float, it's up to 3.0e-8.
: it makes sense to me.
: however, if you would, please take a look at
: page 717 in http://www.library.cornell.edu/nr/bookcpdf/c16-2.pdf.
: i am still confused about what epsion value it could be. In the book, it says
: "the number like 10e-6 or whatever...." i am very confused about what does
: "whatever" mean.
: best wishes,
: Wilson

K*****N
发帖数: 117
8
thanks all. I got it. by testing, it seems that eps (or more precisely,
i should say tolerance?!) i could set up in the program is about 1.0e-33
for double, but for float it's about 1.0e-15. any higher precision above
these two number will have error message (underflow).
thanks again.
wishes

【在 b*****y 的大作中提到】
:
: They talked about solving a system of ODEs which consists of state variables
: with different magnitudes. If you want to solve the system with one tolerance,
: you have to make sure every equation achieve that accuracy. 10e-06 means
: the tolerance (eps here). The scaling part comes in because some state
: variables may not need such a high accuracy as 1e-06, so you use scaling
: vector to make the magnitudes of state variables close to each other.
: To clarify the terminology, in double precision under IE

K*****N
发帖数: 117
9
you suggest me to test:
if (fabs(y[i])+fabs(yscal[i]*eps)) > fabs(y[i])
printf("double is enough\n");
in that case, eps for double could be much smaller. but that's probably
not the right way to test, since the algorithm is not as what you and I had
thought. bascially, it compare:
if ( delta1 < yscal[i]*eps )
next step;
else
decrease the stepsize;
where delta1 is the estimated error.
so in such case, eps could be much smaller.
but your other suggestion is very helpful for me. thank u v

【在 h***o 的大作中提到】
: btw...you can also test if 'double' is enough for your ESP
: as long as you know the scale values for your problem.
: basically, a good numerical routine/function should be able to
: notice the underflow problem. for example page 714 of NR in C
: "if ((float)(x+h) == x) nrerror("step size too small in routine rkdmb");"

h***o
发帖数: 539
10
hehe...in this case it really depends on which variable is
the smallest, yscale or stepsize.

【在 K*****N 的大作中提到】
: you suggest me to test:
: if (fabs(y[i])+fabs(yscal[i]*eps)) > fabs(y[i])
: printf("double is enough\n");
: in that case, eps for double could be much smaller. but that's probably
: not the right way to test, since the algorithm is not as what you and I had
: thought. bascially, it compare:
: if ( delta1 < yscal[i]*eps )
: next step;
: else
: decrease the stepsize;

K*****N
发帖数: 117
11
hehe. now i understand better. eps value somehow is different machine
accuarcy. eps value could be very small for double, like eps=1.0e-30 is
okay by using "double".
however, on the other hand, if u have some expression, like 1.0+eps, then
it might be hurt by declair "double". therefore, instead, you still need
use "long double"..

【在 h***o 的大作中提到】
: hehe...in this case it really depends on which variable is
: the smallest, yscale or stepsize.

1 (共1页)
进入Computation版参与讨论
相关主题
计算! 计算!谁有数值解两个(2D)Ito SDE的经验啊?
直接用NR的源程序需要注意什么吗?推荐numerical解ODE方面的书
ANSI C下如何转换十进制小数为十六进制小数累计误差怎么怎 么 这 么 大 ?
如何高速计算这个积分simulation of a set of stochastic ODE
老大们再帮一把吧是不是cygwin问题?
问个专业问题,请帮助看看在matlab中,如何提高ode45的求解速度呢?
maple ODE 方程组求解问题高手教教怎么在fortran里头call c++的function阿?
[help]should I switch from Matlab to C?!!! How to adjust precision in CPLEX !!!
相关话题的讨论汇总
话题: double话题: eps话题: precision话题: 1e话题: numerical