Home Forums Actuarial Resources & Blogs Computer programs to calculate single life (x) APVs

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #25101
    Richard Purvey
    Participant

      Computer programs to calculate single life (x) actuarial present values

      Computer programs to calculate single life (x) actuarial present values, using a life table

      FIRST COMPUTER PROGRAM

      The computer program below will calculate and display the APV of an n-year temporary immediate life annuity, with a discount factor of v, of 1 per year payable once a year for (x) for the values x=z up to and including x=h, in steps of 1, using a life table in the form of x=xlowest up to and including x=xhighest, in steps of 1, with corresponding lx values l(xlowest), l(xlowest+1),…, l(xhighest-1) and l(xhighest).

      With v equal to 1, the resulting APV will have the same numerical value as the curtate life expectancy.

      Provided l(xhighest)=0, a high enough value for n will result in a whole life APV being calculated.

      10 INPUT xlowest,xhighest

      20 DIM l(xhighest)

      30 FOR x=xlowest TO xhighest

      40 INPUT l(x)

      50 NEXT x

      60 INPUT z,h

      70 INPUT n,v

      80 FOR x=z TO h

      90 IF n>xhighest-x THEN n=xhighest-x

      100 ANSWER=0

      110 FOR r=1 TO n

      120 ANSWER=ANSWER+v^r*l(x+r)

      130 NEXT r

      140 ANSWER=ANSWER/l(x)

      150 PRINT x;” “;ANSWER

      160 NEXT x

      170 GOTO 60

      SECOND COMPUTER PROGRAM

      The computer program below will calculate the following four APVs and display them in this order;

      APV of an n-year temporary life annuity due, with a discount factor of v, of 1 per year payable once a year for (x)

      APV of an endowment insurance, with a discount factor of v, of 1, where the death benefit is payable at the end of the year of death for (x), provided this occurs within n years

      APV of a death benefit, with a discount factor of v, of 1 payable at the end of the year of death for (x), provided this occurs within n years

      APV of a pure endowment, with a discount factor of v, of 1 payable after n years as long as (x) is still alive then

      for the values x=z up to and including x=h, in steps of 1, using a life table in the form of x=xlowest up to and including x=xhighest, in steps of 1, with corresponding lx values l(xlowest), l(xlowest+1),…, l(xhighest-1) and l(xhighest).

      Provided l(xhighest)=0, a high enough value for n will result in a whole life APV being calculated.

      10 INPUT xlowest,xhighest

      20 DIM l(xhighest)

      30 FOR x=xlowest TO xhighest

      40 INPUT l(x)

      50 NEXT x

      60 INPUT z,h

      70 INPUT n,v

      80 FOR x=z TO h

      90 IF n>xhighest-x THEN n=xhighest-x

      100 ANSWER=0

      110 FOR r=0 TO n-1

      120 ANSWER=ANSWER+v^r*l(x+r)

      130 NEXT r

      140 ANSWER=ANSWER/l(x)

      150 ANSWER2=1-(1-v)*ANSWER

      160 ANSWER3=ANSWER2-v^n*l(x+n)/l(x)

      170 ANSWER4=ANSWER2-ANSWER3

      180 PRINT x;” “;ANSWER;” “;ANSWER2;” “;ANSWER3;” “;ANSWER4

      190 NEXT x

      200 GOTO 60

      Computer programs to calculate single life (x) actuarial present values, using a survival function

      FIRST COMPUTER PROGRAM

      Making line 10

      10 DEF FNS(U)=whatever the survival function, S(U), is,

      for example,

      10 DEF FNS(U)=EXP(-0.00022*U-2.7*10^(-6)*(1.124^U-1)/LN(1.124)),

      and then adding the lines below, will result in a computer program which will calculate and display the APV of an n-year temporary immediate life annuity, with a discount factor of v, of 1 per year payable m times per year for (x) for the values x=z up to and including x=h, in steps of 1/m, using a survival function, S(U).

      m normally equals 1, 2, 3, 4, 6 or 12.

      With m equal to 1 and v equal to 1, the resulting APV will have the same numerical value as the curtate life expectancy.

      Provided S(U) tends to 0 as U tends to infinity, a high enough value for n will result in a whole life APV being calculated.

      20 INPUT z,h

      30 INPUT m,n,v

      40 FOR x=z TO h STEP 1/m

      50 ANSWER=0

      60 FOR r=1 TO m*n

      70 ANSWER=ANSWER+v^(r/m)*FNS(x+r/m)

      80 NEXT r

      90 ANSWER=ANSWER/(m*FNS(x))

      100 PRINT x;” “;ANSWER

      110 NEXT x

      120 GOTO 20

      SECOND COMPUTER PROGRAM

      Making line 10

      10 DEF FNS(U)=whatever the survival function, S(U), is,

      for example,

      10 DEF FNS(U)=EXP(-0.00022*U-2.7*10^(-6)*(1.124^U-1)/LN(1.124)),

      and then adding the lines below, will result in a computer program which will calculate the following four APVs and display them in this order;

      APV of an n-year temporary life annuity due, with a discount factor of v, of 1 per year payable m times per year for (x)

      APV of an endowment insurance, with a discount factor of v, of 1, where the death benefit is payable at the end of the 1/m year of death for (x), provided this occurs within n years

      APV of a death benefit, with a discount factor of v, of 1 payable at the end of the 1/m year of death for (x), provided this occurs within n years

      APV of a pure endowment, with a discount factor of v, of 1 payable after n years as long as (x) is still alive then

      for the values x=z up to and including x=h, in steps of 1/m, using a survival function, S(U).

      m normally equals 1, 2, 3, 4, 6 or 12.

      Provided S(U) tends to 0 as U tends to infinity, a high enough value for n will result in a whole life APV being calculated.

      20 INPUT z,h

      30 INPUT m,n,v

      40 FOR x=z TO h STEP 1/m

      50 ANSWER=0

      60 FOR r=0 TO m*n-1

      70 ANSWER=ANSWER+v^(r/m)*FNS(x+r/m)

      80 NEXT r

      90 ANSWER=ANSWER/(m*FNS(x))

      100 ANSWER2=1-m*(1-v^(1/m))*ANSWER

      110 ANSWER3=ANSWER2-v^n*FNS(x+n)/FNS(x)

      120 ANSWER4=ANSWER2-ANSWER3

      130 PRINT x;” “;ANSWER;” “;ANSWER2;” “;ANSWER3;” “;ANSWER4

      140 NEXT x

      150 GOTO 20

       

      Richard Purvey May 2024

       

       

       

       

       

       

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.