// Numbas version: exam_results_page_options {"name": "number of time periods - annuity due", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["period", "ipadec", "ipa", "P", "nseed", "C", "Rnum", "Rden", "Rcf", "nRnum", "nRden", "num", "den", "cf", "nnum", "nden", "compnum", "n", "nrounded"], "preamble": {"css": "", "js": ""}, "variablesTest": {"maxRuns": 100, "condition": ""}, "parts": [{"variableReplacements": [], "marks": 0, "prompt": "

Suppose you borrow $\\$\\var{P}$ to buy a house and you make {period[0]} repayments of $\\$\\var{C}$ at the beginning of each {period[2]}. Interest is $\\var{ipa}\\%$ per annum compounding {period[0]}. Calculate how many {period[2]+'s'} it will take to pay off the loan.

\n

\n

 [[0]] {period[2]+'s'}

", "useCustomName": false, "gaps": [{"maxValue": "nrounded", "variableReplacements": [], "allowFractions": false, "marks": 1, "mustBeReducedPC": 0, "minValue": "nrounded", "useCustomName": false, "showFeedbackIcon": true, "showCorrectAnswer": true, "unitTests": [], "customName": "", "customMarkingAlgorithm": "", "correctAnswerFraction": false, "correctAnswerStyle": "plain", "extendBaseMarkingAlgorithm": true, "mustBeReduced": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "scripts": {}, "showFractionHint": true, "notationStyles": ["plain", "en", "si-en"]}], "showFeedbackIcon": true, "showCorrectAnswer": true, "unitTests": [], "customName": "", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "type": "gapfill", "variableReplacementStrategy": "originalfirst", "scripts": {}, "sortAnswers": false}], "variable_groups": [], "extensions": [], "advice": "

You are asked to find the number of time periods of an annuity due (since the payments are at the beginning of each period) and we are given the present value of the annuity. Therefore we will use the present value of an annuity due formula 

\n

$\\displaystyle P=\\frac{C}{i}\\left(1-\\frac{1}{(1+i)^n}\\right)(1+i)$

\n

where $P$ is the present value, $C$ is the cash flow per period, $i$ is the interest rate per period, and $n$ is the number of periods.

\n

In our situation we have,

\n

$P=\\var{P}$,

\n

$C=\\var{C}$,

\n

$i=\\frac{\\var{ipa}\\%}{\\var{period[1]}}=\\frac{\\var{ipadec}}{\\var{period[1]}}$, 

\n

and therefore we have

\n

$\\displaystyle \\var{P}=\\frac{\\var{C}}{\\left(\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)}\\left(1-\\frac{1}{\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)^n}\\right)\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)$

\n

which we need to rearrange to solve for $n$. Note there are various methods that could be used, the following is one approach that uses the most basic operations and logs. Alternatively, you could use a faster, more sophisticated approach using negative powers or reciprocals.

\n

\n

We want to get $n$ by itself. We start by multiplying both sides by $\\left(\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)$ (to remove the division by it on the right hand side)

\n

$\\displaystyle \\var{P}\\left(\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)=\\var{C}\\left(1-\\frac{1}{\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)^n}\\right)\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)$

\n

Now we will divide both sides by $\\var{C}$ (to remove the multiplication by it on the right hand side)

\n

$\\displaystyle \\frac{\\var{P}}{\\var{C}}\\left(\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)=\\left(1-\\frac{1}{\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)^n}\\right)\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)$

\n

Now we will divide both sides by $\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)$ (to remove the multiplication by it on the right hand side)

\n

$\\displaystyle \\frac{\\frac{\\var{P}}{\\var{C}}\\left(\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)}{\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)}=\\left(1-\\frac{1}{\\left(1+\\simplify[unitDenominator]{{ipadec}/{period[1]}}\\right)^n}\\right)$

\n

Tidying this up a bit (including using a calculator) we have 

\n

\n

$\\displaystyle \\frac{\\var{nnum}}{\\var{nden}}=1-\\frac{1}{\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n}$

\n

We add $\\displaystyle\\frac{1}{\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n}$ to both sides

\n

$\\displaystyle \\frac{\\var{nnum}}{\\var{nden}}+\\frac{1}{\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n}=1$

\n

Then subtract $\\displaystyle \\frac{\\var{nnum}}{\\var{nden}}$ from both sides

\n

$\\displaystyle \\frac{1}{\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n}=1-\\frac{\\var{nnum}}{\\var{nden}}$

\n

Tidying this up we get 

\n

$\\displaystyle \\frac{1}{\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n}=\\frac{\\var{compnum}}{\\var{nden}}$

\n

We multiply both sides by $\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n$ so that the $n$ is not on the bottom of the fraction

\n

$\\displaystyle 1=\\frac{\\var{compnum}}{\\var{nden}}{\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n}$

\n

Now multiply both sides by $\\var{nden}$ to remove the division by it 

\n

$\\displaystyle \\var{nden}=\\var{compnum}\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n$

\n

Now divide both sides by $\\var{compnum}$ to remove the multiplication by it

\n

$\\displaystyle \\frac{\\var{nden}}{\\var{compnum}}=\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n$

\n

Now we take the log of both sides

\n

$\\displaystyle \\log\\left(\\frac{\\var{nden}}{\\var{compnum}}\\right)=\\log\\left(\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)^n\\right)$

\n

In order to apply the log law that allows us to bring the power, $n$, down (that is, $\\log(x^n)=n\\log(x)$) 

\n

$\\displaystyle \\log\\left(\\frac{\\var{nden}}{\\var{compnum}}\\right)=n\\log\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)$

\n

Finally, we divide both sides by $\\log\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)$ to get $n$ by itself

\n

$\\displaystyle \\frac{\\log\\left(\\frac{\\var{nden}}{\\var{compnum}}\\right)}{\\log\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)}=n$

\n

\n

Calculating this we find 

\n

$n\\approx \\var{n}$

\n

but we don't round this in the traditional sense since if we rounded down we wouldn't have paid off the entire loan, therefore we always round up to the nearest whole number.

\n

That is, we need to wait $\\var{nrounded}$ time periods.

", "name": "number of time periods - annuity due", "variables": {"period": {"templateType": "anything", "definition": "['monthly',12,'month']", "description": "", "name": "period", "group": "Ungrouped variables"}, "ipadec": {"templateType": "anything", "definition": "random(0.01..0.06#0.0001)", "description": "", "name": "ipadec", "group": "Ungrouped variables"}, "ipa": {"templateType": "anything", "definition": "ipadec*100", "description": "", "name": "ipa", "group": "Ungrouped variables"}, "nRnum": {"templateType": "anything", "definition": "Rnum/Rcf", "description": "", "name": "nRnum", "group": "Ungrouped variables"}, "Rnum": {"templateType": "anything", "definition": "10000*period[1]+ipa*100", "description": "", "name": "Rnum", "group": "Ungrouped variables"}, "nden": {"templateType": "anything", "definition": "den/cf", "description": "", "name": "nden", "group": "Ungrouped variables"}, "cf": {"templateType": "anything", "definition": "gcd(num,den)", "description": "", "name": "cf", "group": "Ungrouped variables"}, "C": {"templateType": "anything", "definition": "tonearest(P*(ipadec/period[1])/(1-1/(1+ipadec/period[1])^nseed),25)", "description": "", "name": "C", "group": "Ungrouped variables"}, "P": {"templateType": "anything", "definition": "random(100000..1000000#1000)", "description": "", "name": "P", "group": "Ungrouped variables"}, "den": {"templateType": "anything", "definition": "precround(C*(10000*period[1]+ipa*100),0)", "description": "", "name": "den", "group": "Ungrouped variables"}, "Rden": {"templateType": "anything", "definition": "10000*period[1]", "description": "", "name": "Rden", "group": "Ungrouped variables"}, "nseed": {"templateType": "anything", "definition": "random(10*12..30*12)", "description": "

this is roughly the answer to n to ensure that we are paying off more than interest is putting on. We don't use this as the answer because we will be rounding so the amount looks nice.

", "name": "nseed", "group": "Ungrouped variables"}, "compnum": {"templateType": "anything", "definition": "nden-nnum", "description": "", "name": "compnum", "group": "Ungrouped variables"}, "num": {"templateType": "anything", "definition": "precround(P*ipa*100,0)", "description": "", "name": "num", "group": "Ungrouped variables"}, "n": {"templateType": "anything", "definition": "log(nden/compnum)/log(nRnum/nRden)", "description": "

\\frac{\\log\\left(\\frac{\\var{nden}}{\\var{compnum}}\\right)}{\\log\\left(\\frac{\\var{nRnum}}{\\var{nRden}}\\right)

\n

(log(1/(1-P*(ipadec/period[1])/C)))/(log((1+ipadec/period[1]))) gives complex after applying ceiling?!

", "name": "n", "group": "Ungrouped variables"}, "nnum": {"templateType": "anything", "definition": "num/cf", "description": "", "name": "nnum", "group": "Ungrouped variables"}, "nRden": {"templateType": "anything", "definition": "Rden/Rcf", "description": "", "name": "nRden", "group": "Ungrouped variables"}, "nrounded": {"templateType": "anything", "definition": "ceil((n))", "description": "", "name": "nrounded", "group": "Ungrouped variables"}, "Rcf": {"templateType": "anything", "definition": "gcd(Rnum,Rden)", "description": "", "name": "Rcf", "group": "Ungrouped variables"}}, "statement": "

If you are unsure of how to do a question, click on Reveal answers to see the full working. Then, once you understand how to do the question, click on Try another question like this one to start again. Do each question repeatedly to ensure you have mastered it.

", "metadata": {"description": "Financial maths. number of time periods to pay off a loan
", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "functions": {}, "rulesets": {}, "tags": [], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}]}], "contributors": [{"name": "Ben Brawn", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/605/"}]}