// Numbas version: finer_feedback_settings {"name": "Linear recurrence relations of order 1", "extensions": ["random_person"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Linear recurrence relations of order 1", "tags": [], "metadata": {"description": "Formulate a recurrence relation (= difference equation) and solve this recurrence relation.
", "licence": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International"}, "statement": "

In this assessment you always have to enter fractions (no decimals), unless the number is an integer!

", "advice": "

a) Since the daily decrease percentage of {chem} is \\(\\var{dpct}\\) %, and since the daily use of 1 ml medication daily  adds $\\var{s}$ mg of {chem}, we have
\\[ y_{t+1} = y_t - \\var{d} \\cdot y_t + \\var{s} =  \\var{1-d} \\cdot y_t + \\var{s} \\]
or without using decimal forms
\\[ y_{t+1} = y_t - \\simplify[all,fractionNumbers]{{dpct}/100} \\cdot y_t + \\var{s} =  \\simplify[all,fractionNumbers]{{100-dpct}/100} \\cdot y_t + \\var{s} \\]

\n

\\[\\]

\n

b) You obtain the general solution to a first order recurrence equation by adding the general solution to the associated homogeneous recurrence equation and a \"particular\" solution to the original recurrence equation.

\n

The associated homogeneous recurrence equation \\( y_{t+1} =  \\simplify[all,fractionNumbers]{{100-dpct}/100} \\cdot y_t  \\) has as general solution
\\[ y_t^{H} = C \\cdot \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t   ,\\]
with $C$ a real number.

\n

To find a particular solution to the original recurrence equation, you can imitate the right-hand side of 
\\[ y_{t+1} -  \\simplify[all,fractionNumbers]{{100-dpct}/100} \\cdot y_t = \\var{s} .\\]
Assume \\(  y_t = \\alpha\\) with \\(  \\alpha \\) a real number, then \\(  y_{t+1} = \\alpha\\), implying
\\[ \\alpha -  \\simplify[all,fractionNumbers]{{100-dpct}/100} \\cdot \\alpha = \\var{s} \\]
This leads to
\\[ \\alpha = \\simplify[all,fractionNumbers]{{100*s}/{dpct}}  .\\]

\n

Consequently, the general solution is \\[ y_t = C \\cdot \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t   + \\simplify[all,fractionNumbers]{{100*s}/{dpct}}  .\\]

\n

Since \\( y_0 = \\var{b} \\), you can solve  \\( C \\) from \\[ \\var{b}= C  + \\simplify[all,fractionNumbers]{{100*s}/{dpct}}  ,\\] i.e.
\\[  C =  \\simplify[all,fractionNumbers]{{b-100*s/{dpct}}}  .\\]

\n

The final solution to the recurrence equation with the given initial condition is 
\\[ y_t = \\simplify[all,fractionNumbers]{{b-100*s/{dpct}}} \\cdot \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t   + \\simplify[all,fractionNumbers]{{100*s}/{dpct}}  .\\]

\n

\\[\\]

\n

c) The long run concentration (in mg) of {chem} in {person['name']}'s blood is the limit value for  \\(t\\) going to \\( +\\infty \\) of the solution \\( y_t \\) supra:
\\[  \\simplify[all,fractionNumbers]{{100*s}/{dpct}}  .\\]

\n

\\[\\]

\n

d) Suppose that {person['name']} daily uses \\( x \\) ml of medication, then linearity implies a daily increase in the concentration of {chem} in {if(person['gender']='female','her','his')} blood of \\( \\var{s} \\cdot x \\) mg.

\n

The new recurrence equation

\n

\\[ y_{t+1} =   \\simplify[all,fractionNumbers]{{100-dpct}/100} \\cdot y_t + \\var{s} \\cdot x \\]

\n

has as solution

\n

\\[ y_t = C \\cdot \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t   + \\simplify[all,fractionNumbers]{{100*s}/{dpct}} \\cdot x \\]

\n

with resulting long run concentration

\n

\\[  \\simplify[all,fractionNumbers]{{100*s}/{dpct}} \\cdot x .\\]

\n

In order to reach a long run equilibrium of \\( \\var{lt} \\) mg of {chem} in the blood,

\n

\\[  \\simplify[all,fractionNumbers]{{100*s}/{dpct}} \\cdot x =  \\var{lt} ,\\]

\n

i.e.

\n

\\[  x = \\simplify[all,fractionNumbers]{{lt*dpct}/{100*s}} ,\\]

\n

such that {person['name']} needs to use (approximately) \\( \\var{opld} \\) ml of medication on a daily basis.

\n

\\[\\]

\n

e) In this case solving the recurrence relation

\n

\\[ y_{t+1} =   \\simplify[all,fractionNumbers]{{100-dpct}/100} \\cdot y_t + \\simplify[all,fractionNumbers]{{lt*dpct}/{100}} \\]

\n

leads to

\n

\\[ y_t = \\var{b - lt} \\cdot \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t   + \\var{lt}  .\\]

\n

In order to reach, for the first time, less than {Gpct}% of the ideally desired long run limit value of \\( \\var{lt} \\) mg of {chem} in {person['name']}'s blood, you need

\n

\\[  \\var{b - lt} \\cdot \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t   + \\var{lt}  <  \\simplify[all,fractionNumbers]{{Gpct*lt}/{100}}  \\]

\n

which means

\n

\\[  \\var{b - lt} \\cdot \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t     <  \\simplify[all,fractionNumbers]{{(Gpct-100)*lt}/{100}}  \\]

\n

or equivalently

\n

\\[   \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)^t     <  \\simplify[all,fractionNumbers]{{(Gpct-100)*lt}/{100*({b-lt})}}  .\\]

\n

Applying the natural logarithm to the left- and right-hand side gives:

\n

\\[   t \\cdot \\ln \\left( \\simplify[all,fractionNumbers]{{100-dpct}/100} \\right)   <  \\ln \\left( \\simplify[all,fractionNumbers]{{(Gpct-100)*lt}/{100*({b-lt})}}\\right)  ,\\]

\n

i.e.

\n

\\[   t \\cdot (\\var{Ne})  <  \\var{Te} ,\\]

\n

resulting in

\n

\\[   t >  \\var{Be} .\\]

\n

Rounding up leads to the number of  \\(  \\var{ceil(Be)} \\) days in order to reach for the first time less than {Gpct}% of the ideally desired long run limit value \\( \\var{lt} \\) mg {chem} in the blood.

\n

\\[\\]

\n

f) Suppose {person['name']}'s body breaks down $x$% of {chem} daily and {person['name']} daily uses 1 ml of medication, where $ 0 < x < 100$. Then the corresponding recurrence equation
\\[ y_{t+1} = y_t - {\\frac{x} {100}} \\cdot y_t + \\var{s}  ,\\]
has as solution
\\[ y_t = \\left( {\\var{b}}-{\\frac {\\var{100*s}} {x}} \\right)\\cdot \\left( {1 - {\\frac{x} {100}}} \\right)^t   + {\\frac{\\var{100*s}} {x}} ,\\]
resulting in al long run equilibrium of
\\[ {\\frac{\\var{100*s}} {x}} .\\]
For a  long run  concentration of {lt1} mg of {chem} in the blood, this implies
\\[   x =  \\simplify[all,fractionNumbers]{{100*s}/{lt1}} .\\]
So on a daily basis {person['name']}'s body needs (approximately) to break down \\( \\var{oplf} \\) % of {chem} in {if(person['gender']='female','her','his')} blood.

", "rulesets": {}, "extensions": ["random_person"], "variables": {"opld": {"name": "opld", "group": "Ungrouped variables", "definition": "decimal(round(100*lt*d/s)/100)", "description": "", "templateType": "anything"}, "d1": {"name": "d1", "group": "Ungrouped variables", "definition": "s/lt1", "description": "", "templateType": "anything"}, "d": {"name": "d", "group": "Ungrouped variables", "definition": "dpct/100", "description": "", "templateType": "anything"}, "Gpct": {"name": "Gpct", "group": "Ungrouped variables", "definition": "100+g", "description": "", "templateType": "anything"}, "dpct": {"name": "dpct", "group": "Ungrouped variables", "definition": "random(2..20)", "description": "

afbraakpercentage

", "templateType": "anything"}, "g": {"name": "g", "group": "Ungrouped variables", "definition": "random(1..10)", "description": "", "templateType": "anything"}, "verschil": {"name": "verschil", "group": "Ungrouped variables", "definition": "random(1..7)", "description": "

b-lt=verschil

", "templateType": "anything"}, "Be": {"name": "Be", "group": "Ungrouped variables", "definition": "Te/Ne", "description": "", "templateType": "anything"}, "Te": {"name": "Te", "group": "Ungrouped variables", "definition": "ln((Gpct-100)*lt/(100*(b-lt)))", "description": "", "templateType": "anything"}, "Ne": {"name": "Ne", "group": "Ungrouped variables", "definition": "ln(1-d)", "description": "", "templateType": "anything"}, "s": {"name": "s", "group": "Ungrouped variables", "definition": "random(1..5)", "description": "

stijging mg

", "templateType": "anything"}, "oplf": {"name": "oplf", "group": "Ungrouped variables", "definition": "decimal(round(d1pct*100)/100)", "description": "", "templateType": "anything"}, "lt": {"name": "lt", "group": "Ungrouped variables", "definition": "random(2..5)", "description": "

langetermijn

", "templateType": "anything"}, "lt1": {"name": "lt1", "group": "Ungrouped variables", "definition": "random(6..10)", "description": "", "templateType": "anything"}, "person": {"name": "person", "group": "Ungrouped variables", "definition": "random_person()", "description": "", "templateType": "anything"}, "d1pct": {"name": "d1pct", "group": "Ungrouped variables", "definition": "100*d1", "description": "", "templateType": "anything"}, "b": {"name": "b", "group": "Ungrouped variables", "definition": "lt+verschil", "description": "

beginwaarde

", "templateType": "anything"}, "chem": {"name": "chem", "group": "Ungrouped variables", "definition": "random([\"thiotamoline\",\"thiotemoline\",\"thiotomoline\",\"thiotumoline\"])", "description": "", "templateType": "anything"}, "tgrens": {"name": "tgrens", "group": "Ungrouped variables", "definition": "ceil(ln(g*lt/(100*verschil))/ln(1-d))", "description": "", "templateType": "anything"}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["dpct", "s", "lt", "verschil", "b", "d", "g", "Gpct", "tgrens", "lt1", "d1", "d1pct", "opld", "Te", "Ne", "Be", "chem", "person", "oplf"], "variable_groups": [{"name": "Unnamed group", "variables": []}], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "information", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Problem

\n

This morning, at the beginning of the day, {person['name']} had {b} mg of {chem} (a chemical compund) in {if(person['gender']='female','her','his')} blood.
Each day {if(person['gender']='female','she','he')} uses 1 ml of medication, which adds at the beginning of the following day {s} mg of {chem} to {if(person['gender']='female','her','his')} blood.
Daily {if(person['gender']='female','her','his')} body breaks down {dpct}% of the concentration of {chem} that is present at the beginning of the day.
Let $y_t$ be the amount in mg {chem} that will be in {if(person['gender']='female','her','his')} blood in $t$ days at the beginning of the day (consider the time $t$ as a discrete variable).

"}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Formulate a recurrence relation for the sequence $y$ in the form  $y_{t+1} = number1 \\cdot y_t  + number2$ :

\n

       $y_{t+1}$ = [[0]] $\\cdot y_t$ + [[1]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{1-{d}}", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "$n/$n", "partialCredit": 0, "message": "Je mag geen decimalen gebruiken.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{s}", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "$n", "partialCredit": 0, "message": "", "nameToCompare": ""}, "valuegenerators": []}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Solve this recurrence equation with given initial condition, and write this solution in the form  $y_t = number1 \\cdot basenumber^t + number2$.

\n

   $y_t$ = [[0]]  $\\cdot$ [[1]] $+$ [[2]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{b-s/d}", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "`! m_anywhere(decimal:$n)", "partialCredit": 0, "message": "Je mag geen decimalen gebruiken.", "nameToCompare": ""}, "valuegenerators": []}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "(1-{d})^t", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "`! m_anywhere(decimal:$n)", "partialCredit": 0, "message": "Schrijf jouw oplossing als (breuk)^t.", "nameToCompare": ""}, "valuegenerators": [{"name": "t", "value": ""}]}, {"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{s/d}", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "`! m_anywhere(decimal:$n)", "partialCredit": 0, "message": "Je mag geen decimalen gebruiken.", "nameToCompare": ""}, "valuegenerators": []}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

What is in the long run the amount of {chem} (in mg) in {if(person['gender']='female','her','his')} blood?

\n

   [[0]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{100*s}/{dpct}", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "$n/$n`|$n", "partialCredit": 0, "message": "Je mag geen decimalen gebruiken.", "nameToCompare": ""}, "valuegenerators": []}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

Ideally there should be {lt} mg of {chem} in {if(person['gender']='female','her','his')} blood in the long run. Determine the amount of medication (in ml) {if(person['gender']='female','she','he')} should use daily to reach this long run equilibrium. Suppose that the medication linearly increases the amount of {chem} added to the blood.

\n

  [[0]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{lt*d/s}", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "$n/$n`|$n", "partialCredit": 0, "message": "Je mag geen decimalen gebruiken.", "nameToCompare": ""}, "valuegenerators": []}], "sortAnswers": false}, {"type": "gapfill", "useCustomName": false, "customName": "", "marks": 0, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "prompt": "

How many days will it take in order to reach, for the first time, less than {Gpct}% of the ideally desired long run limit value [as proposed in d)] in {person['name']}'s blood?

\n

  [[0]]

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

Suppose {person['name']}'s body does not break down {dpct}% daily, but another (constant) percentage.
What should that percentage be if {if(person['gender']='female','she','he')} is to end up having {lt1} mg of {chem} in the blood in the long run, when {if(person['gender']='female','she','he')} uses 1 ml of medication on a daily basis?

\n

   [[0]]

", "gaps": [{"type": "jme", "useCustomName": false, "customName": "", "marks": 1, "showCorrectAnswer": true, "showFeedbackIcon": true, "scripts": {}, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "answer": "{d1pct}", "answerSimplification": "all,fractionNumbers", "showPreview": true, "checkingType": "absdiff", "checkingAccuracy": 0.001, "failureRate": 1, "vsetRangePoints": 5, "vsetRange": [0, 1], "checkVariableNames": false, "mustmatchpattern": {"pattern": "$n/$n`|$n", "partialCredit": 0, "message": "Je mag geen decimalen gebruiken.", "nameToCompare": ""}, "valuegenerators": []}], "sortAnswers": false}], "type": "question", "contributors": [{"name": "Paul Verheyen", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3610/"}]}]}], "contributors": [{"name": "Paul Verheyen", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3610/"}]}