### Yearly Benefits

We first consider the yearly value of a benefits of 1 payable at the end of the year of death. Term cover can be handled very similarly to the Whole Life case, as set out in the previous post, but limited to a defined term. This can be achieved using similar recursion but using a value of zero when the term reduaces to zero.The code for the memoized version would simply be:1: 2: 3: 4: 5: 6: 7: 8: 9: |
open System.Collections.Generic /// memoized version of Ax1n let rec mem_Ax1n = memoize (fun x n -> // calculate components let px = book_px x let qx = 1.0 - px let v = 1.0/1.05 //calculate result if n>0.0 then v*qx + v*px*(mem_Ax1n (x+1.0) (n-1.0)) else 0.0) |

We can use FCell to load the results into Excel. We can simply reference the function created and generate a grid of A values:

These correspond to the results on page 88 of the book.

### Quarterly Benefits

Now we can do the same for quarterly benefits, which can also be calculated using a very similar recursive approach:1: 2: 3: 4: 5: 6: 7: 8: 9: |
open System.Collections.Generic /// memoized version of quarterly Ax1n let rec mem_Ax1n4 = memoize (fun x n -> // calculate components let px4 = book_px4 x let qx4 = 1.0 - px4 let v4 = (1.0/1.05)**(1.0/4.0) //calculate result if n>0.0 then v4*qx4 + v4*px4*(mem_Ax1n4 (x+1.0/4.0) (n-1.0/4.0)) else 0.0) |

We can use FCell to load the results into Excel. We can simply reference the function created and generate a grid of A values:

These correspond to the results on page 88 of the book.

## No comments:

## Post a Comment