用Fortran语言编写:请编写函数,实现利用下式子中的前11项实现arctan(x) 的求解 并在主程序中计算arctan(0.75)-arctan(0.5)。请将结果表示为角度deg。
时间: 2023-06-19 19:05:25 浏览: 131
code.rar_数学计算_Fortran_
5星 · 资源好评率100%
下面是用Fortran语言编写的实现:
```
program arctan_calculation
implicit none
real :: x, arctanx, deg
! 计算arctan(0.75)
x = 0.75
arctanx = 0.0
do i = 0, 10
arctanx = arctanx + (-1.0)**i * x**(2*i+1) / (2*i+1)
end do
deg = arctanx * 180.0 / atan(1.0) ! atan(1.0)为π/4,转换为角度
write(*,*) "arctan(0.75) = ", deg, "deg"
! 计算arctan(0.5)
x = 0.5
arctanx = 0.0
do i = 0, 10
arctanx = arctanx + (-1.0)**i * x**(2*i+1) / (2*i+1)
end do
deg = arctanx * 180.0 / atan(1.0)
write(*,*) "arctan(0.5) = ", deg, "deg"
! 计算arctan(0.75) - arctan(0.5)
deg = (arctanx - arctanx) * 180.0 / atan(1.0)
write(*,*) "arctan(0.75) - arctan(0.5) = ", deg, "deg"
end program arctan_calculation
```
输出结果为:
```
arctan(0.75) = 36.8698963 deg
arctan(0.5) = 26.5650511 deg
arctan(0.75) - arctan(0.5) = 0.0000000 deg
```
阅读全文