fortran - The accuracy of fortran double precision
问题描述
I have this code when i create epsilons and then write them to a file with other values. The problem is that the values of epsilons i get in the file are not very close to the originals. Here is the code
open(unit=3,file='Avner_Yakov_4_q3.txt')
v0 = 38 ! 85 mph
t_max = x_max/v0;
h = 0.1
phi = pi/4
write(3,*) 'calc order eps delta-y delta-z mone-f'
write(3,*) '------------------------------------------------------'
eps1 = (/ 1d-1, 1d-3, 1d-5, 1d-7 /)
do i=1,4
r = solve_ball(h, t_max, eps1(i), v0, phi,'rk2')
z_max(2) = r(3,ubound(r,2))
y_max(2) = r(2,ubound(r,2))
write(3,"(1i3,1i7,3E12.2,1i6)") i, 2, eps1(i), abs(y_max(2)-y_max(1)), abs(z_max(2)-z_max(1)), ubound(r,2)
!deallocate (r)
end do
do i=1,4
r = solve_ball(h, t_max, eps1(i), v0, phi,'rk3')
z_max(2) = r(3,ubound(r,2))
y_max(2) = r(2,ubound(r,2))
write(3,"(1i3,1i7,3E12.2,1i6)") i+4, 3, eps1(i), abs(y_max(2)-y_max(1)), abs(z_max(2)-z_max(1)), ubound(r,2)
! deallocate (r)
end do
close(unit=3)
And the output
calc order eps delta-y delta-z mone-f
------------------------------------------------------
1 2 0.99E-01 0.14E-01 0.74E-01 5
2 2 0.59E-03 0.19E-01 0.10E+00 7
3 2 0.42E-05 0.91E-02 0.48E-01 50
4 2 0.24E-07 0.61E-03 0.32E-02 476
5 3 0.99E-01 0.34E-01 0.18E+00 28
6 3 0.59E-03 0.24E-01 0.13E+00 8
7 3 0.22E-05 0.77E-02 0.41E-01 10
8 3 0.84E-08 0.45E-02 0.24E-01 50
解决方案
推荐阅读
- javascript - JSZip VUE如何解析promise数组并保存到局部变量
- reactjs - 在 React Native 中多次提示用户权限
- javascript - audio.play() 不等待上一个声音结束?
- vb.net - 如何防止在继承对象时多次执行 NEW() 构造函数中调用的同一个 Sub?- vb.net
- heroku - 无法登录heroku帐户
- scala - 多模块 Scala 项目和声纳扫描仪问题 - 尽管模块不同,但 JUnit 传感器的“无法两次添加相同的测量值”
- docker - 从邮递员访问模拟服务器
- api - 如果产品中有某个关键字,我如何使用此脚本将产品添加到购物篮?
- r - R - 遍历数据框以搜索匹配的主题,然后在匹配时执行操作
- sql - sql中表的最后一行和最后一列的任意字符