Lambert W Function in Finance

The Lambert W Function in Finance

Estimated Read Time: 12 minute(s)
Common Topics: rate, lambert, payment, interest, function

Preamble

The classical mathematician practically by instinct views the continuous process as the “real” process, and the discrete process as an approximation to it. The mathematics of finance and certain topics in the modern theory of stochastic processes suggest that, in some cases at least, the opposite is true. Continuous processes are, generally speaking, the more easily handled of the two – which accounts for their central role in the development of 18th and 19th-century pre-computer mathematics, physics, and engineering.

The basic distinction between the two processes may be illustrated as follows. Monies paid into a fund in the financial world are paid at discrete – usually equally spaced – points in calendar time. In the continuous process, the payment is made continuously, as one might pour fluid from one container into another, where the rate of payment is the fundamental quantity.

Continuous Financial Processes by R. E. Beckwith. Journal of Financial and Quantitative Analysis, 1968, vol. 3, issue 2, 113-133

Continuous Compounding: Introduction

Many readers will be familiar with the concept of “continuously compounded” interest whereby interest is compounded at increasingly small time intervals until a limiting value is reached. Suppose (for example) we have a nominal (annual) interest rate of ##10\% ## compounded monthly. Then each unit of currency (we will not use any particular currency unit) will compound to the following value over a year:

\begin{equation} A_{12} = 1\times\left(1+\frac{0.1}{12}\right)^{12} = 1.1047 \end{equation}

Thus a nominal rate of ##10\% ## year will yield an “effective” rate of ##10.47\% ## if compounded monthly. Obviously, if we compound weekly, the “effective” rate will increase albeit marginally:

\begin{equation} \textstyle A_{52} = 1\times\left(1+\frac{0.1}{52}\right)^{52} = 1.1051 \end{equation}

In the two given examples, the respective compounding frequencies (per year) are 12 and 52 respectively and we ask the question of what will happen if compounding frequency n is increased indefinitely such that n tends to infinity. We find:

\begin{equation}\label{limiting}\textstyle A_{\infty} = \lim_{n\to\infty} 1\times\left(1+\frac{0.1}{n}\right)^n =e^{0.1} \approx 1.1052 \end{equation}

Hence a nominal ##10\% ## annual interest rate has a limiting “effective” rate of ##10.52\% ##. Intuitively, if we consider the standard expansion of ##e^x ##:

\begin{equation}\textstyle e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + \cdots = \sum_{n\geq 0} \frac{x^n}{n!} \end{equation}

then it should be clear that for ##x \ll 1 ##, we have ##e^x \approx 1+x ## or (conversely) ##1+x\approx e^x ##. Hence:

\begin{equation}\textstyle \left(1+\frac{0.1}{52}\right)^{52} \approx {e^{\frac{0.1}{52}}}^{52}=e^{0.1} \end{equation}

Application to Future and Present Value Formulae

Whilst continuous compounding is quite a well-known concept, much less common is the application of similar ideas to the present and future value formulas commonly employed to calculate monthly payments on home loans or – for that matter – any form of loan in which repayment is effected through a series of fixed period (typically monthly) payments. Consider for example the well-known future value formula:

\begin{equation}\textstyle F_v=\dfrac{x\left((1+i_{12})^{n}-1\right)}{i_{12}} \end{equation}

where ##i_{12} ## indicates a monthly interest rate and n is the number of months in the loan period. x is the monthly payment required to achieve a future value “target” amount ##F_v ##. Let r be the annual interest rate and let the loan period be T years. Then we may re-write the above formula in the following form:

\begin{equation}F_v=\dfrac{x\left(\left(1+\frac{r}{12}\right)^{12T}-1 \right)}{\frac{r}{12}}=\dfrac{12x\left(\left(1+\frac{r}{12}\right)^{12T}-1 \right)}{r} \end{equation}

The equation is now in a form that enables us to increase the payment frequency from monthly (12 per year) towards infinity at which point we may implement the previously obtained limiting formula (\ref{limiting}) albeit with the ##10\% ## per annum interest rate replaced by a more general ##r\% ## per annum. Note that the “12” originally in denominator ##\frac{r}{12}## has been brought to the numerator. ##12x## is therefore an annual payment amount. When the payment frequency n is taken towards infinity the per period payment “x” becomes smaller and smaller but “nx” will always represent an annual payment rate which we designate as ## M_a ## in the limiting formula:

\begin{equation}\textstyle F_v=\dfrac{M_a (e^{rT}-1)}{r} \end{equation}

In similar fashion we can manipulate the Present Value formula:

\begin{equation} \textstyle P_v=\dfrac{x\left(1-(1+i_{12})^{-n}\right)}{i_{12}} \end{equation}

into the form:

\begin{equation}\textstyle P_v=\dfrac{x\left(1-(1+\frac{r}{12})^{-12T}\right)}{\frac{r}{12}}=\dfrac{12x\left(1-(1+\frac{r}{12})^{-12T}\right)}{r} \end{equation}

Taking payment frequency from 12 towards infinity, we obtain a continuous form analog of the above discrete frequency formula:

\begin{equation}\label{continuous} \textstyle P_v=\dfrac{M_a (1-e^{-rT})}{r} \end{equation}

It should be noted that the annual payment rate ##M_a## in the above formula is the limiting value of annual payment on a loan ##P_0## if the frequency of payment is increased towards infinity.  If – in the discrete case – the per period payment is x and there are n periods per annum, then:

\begin{equation}\label{pmtlimit} M_a =  \lim_{n\to\infty} nx = \lim_{n\to\infty} \dfrac{P_0 r}{{\left(1-(1+\frac{r}{n})^{-nT}\right)}}=\frac{P_0 r}{1-e^{-rT}} \end{equation}

Effect of Increasing Frequency of Payment

In a manner similar to increasing compounding frequency until a limiting value (\ref{limiting}) is reached, the linked Desmos table and graph shows the effect on accumulated annual payment for a loan if we increase payment frequency starting from per annum (n=1)  followed by semi-annual (n=2), quarterly (n=4), monthly (n=12), weekly (n=52) and daily (n=365) through to the continuous payment limit (##n=\infty##)  determined from Equation (\ref{pmtlimit}) above.

The table shows a set of values for calculated per period payment and corresponding annual payment based on a loan of one million currency units amortized over 30 years at an annual interest rate ##r\approx 11.63\%##. As can be seen, there is not much advantage to be had by increasing frequency from n=12 (monthly) all the way to the continuum limit (##n=\infty##) of 120000 currency units shown as a blue line on the graph. The borrower will save just 64 currency units in 120000 per annum!

https://www.desmos.com/calculator/zxcr4jpwr5

Solving for other Loan Parameters: Continuous Form Model

Annual Payment Rate

Equation (\ref{pmtlimit}) gives us an expression for the annual payment rate on a “continuous repayment loan” ##P_0##: $$M_a = \dfrac{P_0 . r} {1-e^{-rT}}.$$ In theory, we could obtain an annual payment rate using this formula and then pay it off at a frequency of choice (not less than 12 – ie monthly). This looks very much like an ordinary discrete monthly payment but with the proviso that the monthly amounts are deemed to “flow” continuously into the receiving account as described in the Preamble to this article. For its part, the theoretical lending institution may deem continuous compounding to be applied to the continuously changing loan balance.

Loan Period

The loan period may be calculated according to the following formula:

\begin{equation} T = \dfrac{1}{r} \times \ln{\dfrac{M_a}{M_a-P_0r} } \end{equation}

Interest Rate

Since the interest rate is just another parameter in the formula, we shall complete this section by presenting the formula whereby it may be calculated. However, the determination of this formula (using the Lambert W function) is the focal point of this article so the following section will provide details showing how the formula is derived.

\begin{equation}\label{lambertw} r=\dfrac{1}{T} \times W_0 \left(\dfrac{-M_aT}{P_0} \times e^{\tfrac{-M_aT}{P_0}}\right) + \dfrac{M_a}{P_0} \end{equation}

Calculation of Interest Rate using the Lambert W Function

We now come to the crux of this article which is the determination of loan interest rate given loan period, annual payment rate, and initial loan amount. At the outset, it should be noted that interest rate determination from the standard ##P_v ## formula is not directly possible. Implementations such as Excel’s “Rate” function and various online loan calculators employ numerical methods – most likely Newton-Raphson. (It should be noted that all of these yield a “per period” interest rate so if -for example – the loan period is specified in months, the output will reflect a monthly interest rate)

Remarkably however – when Wolfram Alpha was asked to solve for interest rate from the continuous formula (\ref{continuous}) – it produced the solution given above (\ref{lambertw}) under the sub-section “Interest Rate”. Serendipitous for the author who had never even come across the Lambert W function until submitting this request! Subsequent investigation showed this particular function has a highly pedigreed history having been worked on by no less than the great Leonhard Euler in addition to Johann Lambert himself. It is also widely applicable in solving a number of important problems in science and engineering as may be seen from browsing through Wikipedia’s article on the function.

For a derivation of the Wolfram Alpha generated formula, the author opened a Physics Forums thread and two contributors provided answers both of which give very good insights into the process of solving equations using the Lambert W function. In essence the equation has to be
re-worked into the form: ##z = xe^x ## in which the inverse function of ##xe^x ## is the Lambert W or productlog function. We can then solve for x as (in this case) ##x=W_0(z) ## where ##W_0 ## is the primary branch of the Lambert W function. In this article we present  the shorter of the two answers but readers will definitely benefit from studying both posts #8 and #9 in the thread entitled “Question on Lambert W function.”

Instead of working backwards, you can solve the original equation by making a variable substitution inspired by the solution that Wolfram found. Start from:

\begin{equation}0=P\,r-M\left(1-e^{-Tr}\right)\end{equation}

and rewrite ##r ## in terms of a new variable} ##s ## defined via} ##r=s+\frac{M}{P} ## to get:

\begin{equation}0=P\,s+Me^{-\frac{MT}{P}}e^{-Ts}\quad\text{or}\quad Me^{-\frac{MT}{P}}e^{-Ts}=-P\,s\end{equation}

Invert both sides of the second equation above:

\begin{equation}\frac{e^{\frac{MT}{P}}e^{Ts}}{M}=-\frac{1}{P\,s}\end{equation}

and multiply through by ##e^{-\frac{MT}{P}}MTs ## to get a solution in terms of Lambert W:

\begin{equation}Ts\,e^{Ts}=-\frac{MT}{P}e^{-\frac{MT}{P}}\Rightarrow Ts=W\left(-\frac{MT}{P}e^{-\frac{MT}{P}}\right)\end{equation}

Finally, convert ##s ## back to the original} ##r ## variable:

\begin{equation}r=\frac{M}{P}+\frac{1}{T}W\left(-\frac{MT}{P}e^{-\frac{MT}{P}}\right)\end{equation}

And you’re done.

Worked Example

For our worked example – in which we will endeavor to demonstrate as much as possible of the above theory – we will work with a loan of one million (the reader may choose currency unit) amortized over 30 years with a monthly payment of 10000. Granted this is not a particularly realistic example since generally – in a loan situation – the per annum interest rate is set and monthly payment calculated rather than the other way round.  However it will suffice for our purposes which is to demonstrate calculation of interest rate (a rarity for exactly the same reason!).

In the following desmos.com graph reference, we implement the above formula (\ref{lambertw}) for determination of interest rate. Desmos.com does not have its own implementation of the Lambert W function so we make use of a user’s contribution which provides a formula to generate and graph the ##W_0 ## branch. On this graph we label the co-ordinates corresponding to the value ##W_0(-we^{-w})## used in our determination of interest rate as per formula. Here ##w= \frac{M_aT}{P_0}=\frac{12 \times 10000 \times 30}{1000000}##.

https://www.desmos.com/calculator/bfbwlintfd

We will make use of the resulting interest rate as a ‘first guess’ in our second desmos.com reference which calculates interest rate from the standard ##P_v ## formula employing the Newton-Raphson iterative technique. We also graph loan balance over the 30 year loan period using the “traditional” formula as well as the continuous analogue. It will be seen that the two graphs are barely discernible from each other.

https://www.desmos.com/calculator/6dpvn44ndr

Exploring the Lambert W Function

In the Physics Forums thread “Question on Lambert W function” (which we have drawn on extensively in this article) , post # 12 notes the following:

For ##x = MT/P \geq 0## it is not possible for} ##f(x) = xe^{-x}## to exceed ##e^{-1}##, so that ##-e^{-1} \leq -xe^{-x}## is always satisfied.

This follows from taking the derivative ##f'(x) = (1 – x)e^{-x}## and observing that this is positive for ##x < 1## and negative for ##x > 1##, so that ##f## attains a global maximum at ##x = 1## where ##f(1) = e^{-1}##.

A useful place to begin experimenting with the Lambert W function is the following implementation of the real branches ## W_0 ## and ## W_{-1}## on desmos (please note that the graphs may take some time to render due to the computation of the Lambert W function branches):

https://www.desmos.com/calculator/wqwoud7uvk

With reference to our solution for interest rate (\ref{lambertw}) it should be noted that there are two solutions – one of these being: ## r= \frac{M_a}{P} – \frac{1}{T} \times \frac{M_aT}{P} = 0 ##. This comes from the ##W_{-1}## branch whereas the solution we are looking for originates in the ##W_0## branch. The two solutions are illustrated in the following edited version of the above-mentioned desmos graph. Wolfram Alpha specifically excludes the ##W_{-1}## solution.

https://www.desmos.com/calculator/vq5qshsyha

Readers may also note the domain of the Lambert W function is restricted to values greater than ##-e^{-1}## as explained above.

 

Summary

In this article , we have presented a brief introduction to continuous compounding as well as its application to determine continuous analogues of the standard present and future value formulae. We have drawn up a set of formulae enabling calculation of any one of the following variables: interest rate, loan amount, loan period and period payment – given the other three. In particular we have explored the use of the Lambert W function in a formula to calculate interest rate. The included worked example has been designed to demonstrate all of the above theory.

A Cautionary Note

Continuous compounding and the continuous form analogues of the standard Future and Present Value formulae are theoretical constructs and are not used in real world financial calculations. The same is true of the Lambert W based formula for annual (or per period) interest rate which is a derivative of the continuous form analogue of the Present Value formula.

We can do no better than quote on appropriate use of these formulae as given in the source article by R.E. Beckwith in “Journal of Financial and Quantitative Analysis”.

“Although the continuous analogs are not ‘exact’ , they are generally of sufficient precision to allow the user to examine rapidly rather complex processes, and to state, develop and approximate solutions of problems that otherwise would be quite forbidding for casual investigation. Moreover, because of the consistent bias of the continuous model, valid relative comparisons can be made of alternative capital investment proposals.

In general, solutions based on the Lambert W function tend to require significant computational resources, although various research endeavors are focused on (have focused on) enhancing the efficiency of the computation process. See for example:

https://www.dafx.de/paper-archive/2019/DAFx2019_paper_5.pdf

Acknowledgements

I would like to expressly thank PF users @topsquark, @renormalize and @pasmith whose contributions in the thread “Question on Lambert W function” greatly assisted in clarifying the concepts explored in this article.

PF user @pbuk kindly reviewed the article and advised caution in presenting theoretical formulae as an alternative to established financial methods and conventions. The section entitled “A Cautionary Note” above  is intended to express such caution explicitly. PF user @PeterDonis also reviewed the article and suggested some changes to clarify certain of the formulae presented in the introductory section on continuous compounding.

The pdf version of this article has undergone several revisions thanks to the contributions of PF users @TomG and @vanhees71. These led to the author researching and learning how to adjust the colors of hypertext links and URLs within a Latex document. Another enhancement is the use of numbered equations and – where necessary – labels that reference them. The latter improvement also reflects in the mainstream article as edited here within the “Insights” editing environment on Physics Forums.

Thanks also to PF users who contributed ‘likes” or brief comments in various threads relating to this article. And as always thanks to @Greg Bernardt for making Physics Forums – and consequently “Insights” articles – possible in the first place!

References

[1]R. E. Beckwith.
Continuous financial processes.
Journal of Financial and Quantitative Analysis, 3(2):113–133,
1968.
bib |
DOI ]
[3]PhysicsForums Contributors.
Question on lambert w function.https://www.physicsforums.com/threads/question-on-lambert-w-function.1057505/.
(Accessed on 01/21/2024).
bib ]
[4]Stephen Wolfram.
Wolfram|alpha: Computational intelligence.
https://www.wolframalpha.com/.
Solve for r: P – M/r(1-exp(-r*T))=0.
bib ]
[5]Wikipedia Contributors.
Lambert w function – wikipedia.
https://en.wikipedia.org/wiki/Lambert_W_function.
(Accessed on 01/26/2024).
bib ]

 

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply