Skip to content

Instantly share code, notes, and snippets.

@potass13
Last active January 25, 2016 14:07
Show Gist options
  • Save potass13/db977dc647c287068f03 to your computer and use it in GitHub Desktop.
Save potass13/db977dc647c287068f03 to your computer and use it in GitHub Desktop.
solve for x : inv(x) = val
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