liuzhiming69的个人博客分享 http://blog.sciencenet.cn/u/liuzhiming69

博文

牛顿迭代法求反三角函数值(VBA)程序

已有 75 次阅读 2025-9-16 08:30 |系统分类:科研笔记

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

上一篇:反三角函数的精确计算
下一篇:Ln(x)的牛顿迭代法求解
收藏 IP: 121.28.181.*| 热度|

1 王涛

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2025-9-19 04:23

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部