Last active
January 25, 2016 14:07
-
-
Save potass13/db977dc647c287068f03 to your computer and use it in GitHub Desktop.
solve for x : inv(x) = val
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function inv(x As Double) As Double | |
' Define involute function | |
inv = Tan(x) - x | |
End Function | |
Function solve_inv(val As Double) As Double | |
' Solve for x : inv(x) = val | |
Dim x0 As Double, x1 As Double | |
Dim eps As Double, pi As Double | |
eps = 0.00001 | |
pi = 4# * Atn(1#) | |
x1 = pi / 4# | |
Do | |
x0 = x1 | |
x1 = x0 - (inv(x0) - val) / Tan(x0) ^ 2 | |
Loop While Abs(x1 - x0) > eps | |
solve_inv = x1 'radian | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment