fortran中三角函数
时间: 2024-02-26 10:59:05 浏览: 434
Fortran90 三角形网格划分
在Fortran中,三角函数可以使用内置函数来计算。下面是一些常用的三角函数及其Fortran函数名称:
- 正弦函数:SIN(x)
- 余弦函数:COS(x)
- 正切函数:TAN(x)
- 反正弦函数:ASIN(x)
- 反余弦函数:ACOS(x)
- 反正切函数:ATAN(x)
其中,x是以弧度为单位的角度值。如果需要将角度转换为弧度,可以使用内置函数RADIAN(x),例如:
```
program trig_functions
implicit none
real :: x = 45.0
real :: radians = RADIAN(x)
write(*,*) 'sin(', x, ') = ', SIN(radians)
write(*,*) 'cos(', x, ') = ', COS(radians)
write(*,*) 'tan(', x, ') = ', TAN(radians)
write(*,*) 'asin(', 0.70710678, ') = ', ASIN(0.70710678)
write(*,*) 'acos(', 0.70710678, ') = ', ACOS(0.70710678)
write(*,*) 'atan(', 1.0, ') = ', ATAN(1.0)
end program trig_functions
```
输出结果:
```
sin( 45.0000000 ) = 0.707106769
cos( 45.0000000 ) = 0.707106769
tan( 45.0000000 ) = 0.999999940
asin( 0.707106769 ) = 0.785398185
acos( 0.707106769 ) = 0.785398185
atan( 1.00000000 ) = 0.785398185
```
阅读全文