Numerius11级分类:VB被浏览98次2013.06.24
麻烦有能力的朋友帮我编个渐开线函数的反函数,最好用vB编写!用什么二分法呀,牛顿法呀,都随便你们,最近忙毕业设计没空研究!题目: 已知 渐开线函数 inv(a)=tan(a) -a (其中a为弧度) 那么现在已知inv(a)的值,麻烦高手帮我编出解出a值的程序!不用把程序给我,写上代码在答案里就行了!十分感谢!
dorhm
采纳率:55%10级2013.06.25
AInv (0.02842) 24.5822867713287 Public Function Inv(a As Double) As Double Inv = Tan(a) - aEnd FunctionPublic Function AInv(num As Double) As Double Dim lowangle As Double Dim highangle As Double Dim midangle As Double lowangle = 0 highangle = Atn(1) * 2 Do While highangle - lowangle > 10 ^ -12 midangle = (lowangle + highangle) / 2 If Inv(midangle) > num Then highangle = midangle Else lowangle = midangle End If Loop AInv = (lowangle + highangle) / 2 / Atn(1) * 45End Function加个牛顿法的Public Function AInv2(num As Double) As Double Dim x1 As Double Dim x2 As Double x2 = Atn(1) Do x1 = x2 x2 = x1 - (Tan(x1) - x1 - num) / (1 / Cos(x1) ^ 2 - 1) Loop While Abs(x2 - x1) > 10 ^ -12 AInv2 = x2 / Atn(1) * 45End Function