Post Reply 
TVM solve for interest rate, revisited
06-10-2022, 08:25 PM (This post was last modified: 06-11-2022 08:23 PM by Albert Chan.)
Post: #7
RE: TVM solve for interest rate, revisited
(05-17-2022 01:31 PM)Albert Chan Wrote:  f = (pv+fv)/n * g + pv * x + pmt = 0      // same formula used for Plus42

g = n*x / ((1+x)^n-1)
g'/g = -(g-1+(n-1)*x) / (x+x^2) = -num / den
g''/g = (g+n*x)*(2*(g-1)+(n-1)*x) / (x+x^2)^2 = (num+x+1)*(num+(g-1)) / den^2

Let k = (pv+fv)/n * g

f = k + pv*x + pmt
f' = k*(g'/g) + pv
f'' = k*(g''/g)

Using first derivative to get to second, Halley's correction is cheap.
To make code more robust, we special cased with limits when rate goes 0

If solution exist, Halley's method seems not to over-shoot, but not yet proved.
However, starting from edge, we can proof no over-shoot for Newton's method

Proof: f is either concave-up, or concave-down (f'' have same sign)

g = n*x / ((1+x)^n-1) = 1 - (n-1)/2*x + (n²-1)/12*x² - (n²-1)/24*x³ + ...

For integer n, g is decaying if n>0, growing if n<0 (= compounding factor C)
Note: if n=1, g=1; if n=-1, g=1+x ⇒ For n=±1, f is a straight line.

g ≥ 1 - (n-1)/2*x            // x=0 tangent line, but inequality holds for other x.
g + (n-1)/2*x - 1 ≥ 0      // if x=0, g=1 ⇒ LHS=0

g''/g = (g+n*x)*(2*(g-1)+(n-1)*x) / (x+x^2)^2
g'' = g^2 * (1+x)^n * 2 * (g+(n-1)/2*x-1) / (x+x^2)^2

Assume n>1:

For -1 < x < ∞, x≠0, RHS all factors are postive ⇒ g'' > 0
Take the limit, g''(x=0) = (n²-1)/6 > 0

g'' is positive thoughtout, except on the edge of x domain:
Take the limit, g''(x=-1) = g''(x=∞) = 0

f'' = (pv+fv)/n * g''      → sign(f'') = sign(pv+fv)

Update:
lua code to automatic rate search, using Newton's 1-sided convergence property.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: TVM solve for interest rate, revisited - Albert Chan - 06-10-2022 08:25 PM



User(s) browsing this thread: 4 Guest(s)