Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi. Kind of an interesting inverse function with the main function
Tan(x) - x There are multiple values for an inverse, so we need to make some assumptions. If x is value Pi/2, then Tan(Pi/2) is infinity. If given a number like 10, or 100, then the inverse is very close to Pi/2. Therefore, if given a number like 10, the first loop of Newton's method most likely will calculate a number on the other side of Pi/2, where the slope reverses. This will cause the calculation not to work. It appears that if given a large number that is very close to a discontinuity, it appears best to make a guess as close to Pi/2 as possible so the next guess stays in the same quadrant. Perhaps something like this if you think you may have numbers greater than about 1. Function RevInv(n) Dim g As Double Dim r As Double Dim Limit As Double Limit = WorksheetFunction.Pi / 2 If n < 1 Then n = Limit / 2 Else g = Limit - 1 / 1000000 Do While r < g r = g g = g - (Tan(g) - g - n) / Tan(g) ^ 2 Loop RevInv = g End Function -- HTH. :) Dana DeLouis Windows XP, Office 2003 <snip |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
User Defined Function | Excel Worksheet Functions | |||
Excel Solver as User Defined Funcntion | Excel Worksheet Functions | |||
Need to open the Function Arguments window from VBA for a user defined function. | Excel Programming | |||
User-defined data type; Error: Only User-defined types... | Excel Programming | |||
User-Defined Function pre-empting Built-in Function? How to undo???? | Excel Programming |