%%HP:T(3)F(.);

@ NONFORF - Programs for calculating adjusted premiums and cash values
@           under the 1941 and 1980 Standard Nonforfeiture Laws.
@
@ When downloaded, this file creates a directory containing the
@ following programs for calculating adjusted premiums and cash values
@ under the 1941 and 1980 Standard Nonforfeiture Laws.  QLIB/48 must
@ be installed before you download the file.
@
@    CV80(x,h,n,e) = n by 1 matrix of the cash values under the 1980 law
@    PA80(x,h,n,e) = adjusted premium under the 1980 law
@    E180(x,h,n,e) = first year expense allowance under 1980 law
@    CV41(x,h,n,e) = n by 1 matrix of the cash values under the 1941 law
@    PA41(x,h,n,e) = adjusted premium under the 1941 law
@    E141(x,h,n,e) = first year expense allowance under 1941 law
@
@ Notes:
@
@ - The QLIB/48 X mortality table, X setback, and interest rate must
@   be set to the desired assumptions before running the programs.
@
@ - The programs calculate values for a general h-pay, n-year $1000 life
@   insurance issued at age x.  Premiums are assumed to be paid at the
@   beginning of each policy year for h years.  Death benefits are assumed
@   to be paid at the end of the policy year of death.
@
@ - Use e=0 for term insurance (no benefit if the insured survives n
@   years) and e=1000 for an insurance with a $1000 endowment benefit
@   at the end of n years.
@
@ - For whole life insurance, set h and/or n to very large numbers.  For
@   example, PA80(x,999,999,0) is the adjusted premium for an ordinary
@   life policy (e doesn't matter here), PA80(x,20,999,0) is the
@   adjusted premium for a 20-pay life, and PA80(x,999,30,1000) and
@   PA80(x,30,30,1000) are the adjusted premium for a 30-year endowment
@   insurance.  Note that h=n is assumed if h>n.
@
@ - The CVyy functions return a column matrix containing the cash values
@   for durations 1..n.  If this matrix is viewed with the MatrixWriter,
@   the row numbers correspond to the policy durations.  For example, the
@   value in row 5 is the cash value at the end of the fifth policy year.
@
@ - The matrices of cash values returned by the CVyy functions do not
@   include zero duration cash values.  A zero duration cash value is
@   just the negative of the first year expense allowance, so the E1yy
@   functions can be used for this.
@
@ References:
@   Bowers, et al., ACTUARIAL MATHEMATICS, first edition
@      (Society of Actuaries, 1986), pp. 433-9.
@   Jordan, LIFE CONTINGENCIES, second edition
@      (Society of Actuaries, 1982), pp. 139-42.
@

DIR



CV80
\<< \-> x h n e \<<
   x h n e
   x h n e PA80
   $CV
   \>>
\>>



PA80
\<< \-> x h n e \<<

   @ Calc reciprocal of h-year temp. annuity (n-year if h>n)
   x DX
   x NX x h n MIN + NX -
   /

   @ Calc net single premium (NSP) of the life insurance
   x MX x n + MX - x DX / 1000 * @ NSP of term insurance
   x n + DX x DX / e * @ NSP of pure endowment, if any
   + @ total NSP for endowment insurance

   @ Calc first year expense allowance
   DUP2 * @ net premium
   40 MIN
   1.25 *
   10 + @ E1=1.25*MIN(P,40)+10

   @ Calc adjusted premium
   + @ NSP+E1
   * @ (NSP+E1)/anty

   \>>
\>>



E180
\<< \-> x h n e \<<
   x h n e
   x h n e PA80
   $E1
   \>>
\>>



CV41
\<< \-> x h n e \<<
   x h n e
   x h n e PA41
   $CV
   \>>
\>>



PA41
\<< \-> x h n e \<<

   @ First calculate ordinary life adjusted premium (PAOL)
   '$PA=(1000*MX(x)/DX(x)+.65*MIN($PA,40)+20)/CLMX(x,0,1)' @ equ. for PAOL
   '$PA' @ solve for $PA (i.e., PAOL)
   40 @ initial guess
   ROOT @ now we have PAOL

   @ Build equation for adjusted premium of the desired life insurance:
   @    $PA=(NSP+0.4*MIN($PA,40)+0.25*MIN($PA,PAOL,40)+20)/anty .
   @ Get expression for first year expense allowance:
   40 MIN @ MIN(PAOL,40)
   '$PA' MIN @ 'MIN($PA,PAOL,40)'
   .25 * @ '.25*MIN($PA,PAOL,40)'
   '.4*MIN($PA,40)'
   + @ now have terms involving $PA
   20 + @ add $20 term of first year expense allowance

   @ Calc NSP for the life insurance
   x MX x n + MX - x DX / 1000 * @ single prem for term insurance
   x n + DX x DX / e * @ single prem for pure endowment, if any
   + @ net single prem for desired insurance
   + @ add with E1 to get total numerator of PA (NSP+E1)

   @ Denominator of PA (premium payment annuity)
   x NX x h n MIN + NX - x DX / @ h-year temp. annuity (n if h>n)
   / @ formula for PA: numerator/denominator

   @ Build equation for PA and solve
   '$PA' = @ equation to be solved
   '$PA' @ the unknown
   $PA @ use PAOL as initial guess
   ROOT @ find the adjusted premium

   @ The only thing remaining on the stack is the adjusted premium.
   \>>
\>>



E141
\<< \-> x h n e \<<
   x h n e
   x h n e PA41
   $E1
   \>>
\>>



$CV @ Calculate CV's given the adjusted premium.
\<< \-> x h n e pa \<<

   pa @ adjusted premium

   @ Get terms of NSP that don't vary by duration
   x n + MX 1000 *
   x n + DX e *
   - @ M[x+n]-e*D[x+n]

   @ Get terms of annuity that don't vary by duration
   x h n MIN + NX @ N[x+h]

   @ Check if x+n is beyond end of table
   IF x n + \GwX > THEN
      \GwX x - 'n' STO
      1000 'e' STO @ ins is essentially endowment at age \GwX ins.
      END

   @ Put CV's on the stack
   \-> pa Mxn Nxh \<<
      1 n 1 - FOR k
         x k + MX 1000 * Mxn -
         x k + NX Nxh - 0 MAX @ use 0 if k>h
         pa *
         -
         x k + DX
         /
         NEXT
      e @ final CV is endowment benefit
      \>>

   @ Build array of CV's
   n { 1 } + @ dimensions
   \->ARRY

   \>>
\>>



$E1 @ Calculate E1 given the adjusted premium.
\<< \-> x h n e pa \<<

   pa @ adjusted premium = (NSP+E1)/anty

   x NX x h n MIN + NX - x DX / @ anty
   * @ NSP+E1

   x MX x n + MX - x DX / 1000 * @ NSP of term ins only
   x n + DX x DX / e * + @ NSP=term ins + endowment
   - @ E1

   \>>
\>>



$PA @ variable to hold 1941 law adjusted premium (needed for ROOT command)
0
