刘志明
牛顿迭代法求反三角函数值(VBA)程序
2025-9-16 08:30
阅读:450

ATAN(x)计算程序:

Dim Pi As Double

Private Sub CommandButton1_Click()

x = Sheet1.Cells(2, 1)

Pi = 3.141592654

If x = 0 Then

Sheet1.Cells(3, 1) = 0

Sheet1.Cells(3, 2) = 0

Exit Sub

End If

x1 = Abs(x)

If Abs(x) > 1 Then

x1 = 1 / Abs(x)

End If

y = x1

L = 0

jd = 0.0000000001

100 If L <= 100000 Then

y1 = y - (Tan(y) - x1) / (1 + (Tan(y)) ^ 2)

If Abs(y1 - y) > jd Then

y = y1

L = L + 1

GoTo 100

End If

End If

Sheet1.Cells(3, 1) = x / Abs(x) * y

If Abs(x) > 1 Then

Sheet1.Cells(3, 1) = x / Abs(x) * (Pi / 2 - y)

End If

Sheet1.Cells(3, 2) = L

End Sub

ASIN(x)计算程序:

Private Sub CommandButton2_Click()

x = Sheet1.Cells(5, 1)

y = x

L = 0

jd = 0.0000000001

100 If L <= 100000 Then

y1 = y - (Sin(y) - x) / Cos(y)

If Abs(y1 - y) > jd Then

y = y1

L = L + 1

GoTo 100

End If

End If

Sheet1.Cells(6, 1) = y

Sheet1.Cells(6, 2) = L

End Sub

转载本文请联系原作者获取授权,同时请注明本文来自刘志明科学网博客。

链接地址:https://wap.sciencenet.cn/blog-3556836-1502150.html?mobile=1

收藏

当前推荐数:1
推荐人:
推荐到博客首页
网友评论0 条评论
确定删除指定的回复吗?
确定删除本博文吗?