// Numbas version: finer_feedback_settings {"name": "Dynamical system 4", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"rulesets": {"std": ["all", "!collectNumbers", "!noLeadingMinus"]}, "metadata": {"notes": "
The definition of the trace is tau=random([0]+repeat(2*random(0..9)*sign(random(-1,1)),5))
, i.e. essentially random(0,n1,n2,n3,n4,n5)
, where ni
is calculated as above. This is so that there is roughly a one in six chance of getting a \"centre\" fixed point. Without this manipulation, the chance of a centre is quite small, since it can only occur when $\\tau=0$ (and $\\delta>0$).
05/11/2013
\nFix definition of c, which should be multiplied by the sign of b, so that the determinant is calculated correctly.
\nFix double shuffling of natures list (once in definition, once in choice list).
\nFix no marks given for correct choice of nature.
\nRemove degenerate node and star node from the list of fixed points. They were never a possibility.
\n14/11/2013:
\nAdded Jsxgraph graphs of the solutions and attempt at a picture of the behaviour at the critical point x=0, y=0. Needs more work on finding the bounding box dimensions dynamically to find the best picture.
\n05/03/2014:
\nChanged variables so that only complex eigenvalues can occur, hence only centres or spirals.
\n04/08/2014
\nChanged showNavigation to false in both functions as this does not work at present - need to upload new version of jsxgraph?
", "description": "Nature of fixed points of a 2D dynamical system.
\nThese examples are either centres or spirals.
", "licence": "Creative Commons Attribution 4.0 International"}, "variables": {"lam1": {"templateType": "anything", "definition": "b*vec1+a", "name": "lam1", "group": "Ungrouped variables", "description": ""}, "r": {"templateType": "anything", "definition": "\n//r=0 gives a center.\nrandom(0,1)\n", "name": "r", "group": "Ungrouped variables", "description": ""}, "be": {"templateType": "anything", "definition": "random(-5..5 except [0,-3,3])", "name": "be", "group": "Ungrouped variables", "description": ""}, "c": {"templateType": "anything", "definition": "m/b", "name": "c", "group": "Ungrouped variables", "description": ""}, "m": {"templateType": "anything", "definition": "(a*d-lam1*lam2)", "name": "m", "group": "Ungrouped variables", "description": ""}, "al": {"templateType": "anything", "definition": "(-1+random(-0.3..0.3#0.02))/be", "name": "al", "group": "Ungrouped variables", "description": ""}, "delta": {"templateType": "anything", "definition": "a*d-b*c", "name": "delta", "group": "Ungrouped variables", "description": ""}, "natures": {"templateType": "anything", "definition": "shuffle(['unstable node','stable node','saddle point','unstable spiral','stable spiral','centre'] except nature)", "name": "natures", "group": "Ungrouped variables", "description": ""}, "vec2": {"templateType": "anything", "definition": "al-be*i", "name": "vec2", "group": "Ungrouped variables", "description": ""}, "disc": {"templateType": "anything", "definition": "tau^2-4*delta", "name": "disc", "group": "Ungrouped variables", "description": ""}, "vec1": {"templateType": "anything", "definition": "al+be*i", "name": "vec1", "group": "Ungrouped variables", "description": ""}, "d": {"templateType": "anything", "definition": "lam1+lam2-a", "name": "d", "group": "Ungrouped variables", "description": ""}, "lam2": {"templateType": "anything", "definition": "b*vec2+a", "name": "lam2", "group": "Ungrouped variables", "description": ""}, "a": {"templateType": "anything", "definition": "if(r=1,random(-3..3 #0.25 except [-b*(revec1+revec2),-b*revec1,0]),-b*al)", "name": "a", "group": "Ungrouped variables", "description": ""}, "b": {"templateType": "anything", "definition": "random(-2..2#0.25 except 0)", "name": "b", "group": "Ungrouped variables", "description": ""}, "tau": {"templateType": "anything", "definition": "a+d", "name": "tau", "group": "Ungrouped variables", "description": ""}, "revec1": {"templateType": "anything", "definition": "al", "name": "revec1", "group": "Ungrouped variables", "description": ""}, "yr": {"templateType": "anything", "definition": "if(rorc=1 and r=0,max(sqrt(((a+b)^2+delta)/delta),sqrt(((c+d)^2+delta)/delta)),100)", "name": "yr", "group": "Ungrouped variables", "description": ""}, "rorc": {"templateType": "anything", "definition": 1, "name": "rorc", "group": "Ungrouped variables", "description": ""}, "s": {"templateType": "anything", "definition": "random(1,-1)", "name": "s", "group": "Ungrouped variables", "description": ""}, "naturetext": {"templateType": "anything", "definition": "\nswitch (\n nature='unstable node', \"because $\\\\lambda_1>0$ and $\\\\lambda_2>0$, the fixed point is an unstable node\",\n nature='stable node', \"because $\\\\lambda_1<0$ and $\\\\lambda_2<0$, the fixed point is a stable node\",\n nature='saddle point', \"because $\\\\lambda_1>0$ and $\\\\lambda_2<0$, the fixed point is a saddle point\",\n nature='unstable spiral', \"because $\\\\mathrm{Im}(\\\\lambda_1)\\\\ne 0$ and $\\\\mathrm{Im}(\\\\lambda_2)\\\\ne 0$, and $\\\\mathrm{Re}(\\\\lambda_1)=\\\\mathrm{Re}(\\\\lambda_2)>0$, the fixed point is an unstable spiral\",\n nature='stable spiral', \"because $\\\\mathrm{Im}(\\\\lambda_1)\\\\ne 0$ and $\\\\mathrm{Im}(\\\\lambda_2)\\\\ne 0$, and $\\\\mathrm{Re}(\\\\lambda_1)=\\\\mathrm{Re}(\\\\lambda_2)<0$, the fixed point is a stable spiral\",\n nature='centre', \"because $\\\\mathrm{Im}(\\\\lambda_1)\\\\ne 0$ and $\\\\mathrm{Im}(\\\\lambda_2)\\\\ne 0$, and $\\\\mathrm{Re}(\\\\lambda_1)=\\\\mathrm{Re}(\\\\lambda_2)=0$, the fixed point is a centre\",\n false\n)\n", "name": "naturetext", "group": "Ungrouped variables", "description": ""}, "xr": {"templateType": "anything", "definition": 10, "name": "xr", "group": "Ungrouped variables", "description": ""}, "revec2": {"templateType": "anything", "definition": "al", "name": "revec2", "group": "Ungrouped variables", "description": ""}, "nature": {"templateType": "anything", "definition": "\nif (im(lam1)=0 and im(lam2)=0,\n switch (\nlam1>0 and lam2>0, 'unstable node',\nlam1<0 and lam2<0, 'stable node',\nlam1>0 and lam2<0, 'saddle point',\nlam1<0 and lam2>0, 'saddle point'\n ),\n switch (\nre(lam1)>0, 'unstable spiral',\nre(lam1)<0, 'stable spiral',\nre(lam1)=0, 'centre'\n )\n)\n", "name": "nature", "group": "Ungrouped variables", "description": ""}}, "advice": "\na)
\nThe elements of the matrix $\\mathsf{A}$ are the coefficients of $x$ and $y$ in the system of equations, hence
\n\\[\\mathsf{A}=\\pmatrix{\\var{a} & \\var{b}\\\\\\var{c} & \\var{d}}.\\]
\n\n
b)
\nThe trace $\\tau$ and determinant $\\delta$ of a matrix
\n\\[\\mathsf{A}=\\pmatrix{a & b\\\\c & d}\\]
\nare given by $\\tau=a+d$ and $\\delta=ad-bc$.
\nA straight forward substitution for $a=\\var{a}$, $b=\\var{b}$, $c=\\var{c}$, and $d=\\var{d}$ reveals that $\\tau=\\var{tau}$ and $\\delta=\\var{delta}$.
\n\n
c)
\nThe eigenvalues $\\lambda$ of a matrix $\\mathsf{A}$ can be calculated from the expression
\n\\[\\mathsf{A}\\boldsymbol{x}=\\lambda\\boldsymbol{x},\\]
\nwhich is equivalent to
\n\\[\\left(\\mathsf{A}-\\lambda\\mathsf{I}\\right)\\boldsymbol{x}=\\boldsymbol{0},\\]
\nwhere $\\mathsf{I}$ is the identity matrix.
\nThis linear system has a solution only when
\n\\[\\det\\left(\\mathsf{A}-\\lambda\\mathsf{I}\\right)=0,\\]
\ni.e. when $(a-\\lambda)(d-\\lambda)-bc=0$. This leads to $\\lambda^2-(a+d)\\lambda+(ad-bc)=0$, which is equivalent to
\n\\[\\lambda^2-\\tau\\lambda+\\delta=0.\\]
\nThe eigenvalues $\\lambda_1$ and $\\lambda_2$ of the matrix $\\mathsf{A}$ are therefore given by
\n\\[\\lambda_{1,2}=\\frac{-\\tau\\pm\\sqrt{\\tau^2-4\\delta}}{2}.\\]
\nFollowing through this calculation for the specific values of $a$, $b$, $c$, and $d$ in this question leads to $\\lambda_1=\\var{lam1}$ and $\\lambda_2=\\var{lam2}$.
\n\n
d)
\nThe eigenvectors corresponding to the eigenvalues $\\lambda_1$ and $\\lambda_2$ can be found by solving the linear system of equations given by
\n\\[\\mathsf{A}\\boldsymbol{x}=\\lambda\\boldsymbol{x},\\]
\nor
\n\\[\\begin{align}ax+by&=\\lambda x,\\\\cx+dy&=\\lambda y,\\end{align}\\]
\nwhere $\\lambda$ is either $\\lambda_1$ or $\\lambda_2$.
\nBecause this is an eigenvalue problem, we can arbitrarily choose one of the eigenvector components to be $1$, the $x$-component in this case. The $y$-component can then be found from
\n\\[y=\\frac{x(\\lambda-a)}{b}\\quad\\text{or}\\quad y=\\frac{cx}{\\lambda-d},\\]
\nwith $x=1$. Both expressions are equivalent, and will lead to the same value for $\\lambda$.
\nMaking the necessary substitutions reveals that the $y$-component of the eigenvector corresponding to $\\lambda_1$ is $\\var{vec1}$, and the $y$-component of the eigenvector corresponding to $\\lambda_2$ is $\\var{vec2}$.
\n\n
e)
\nThe nature of the fixed point at the origin can be determined by examining the eigenvalues. If the eigenvalues are real, then the sign of each eigenvalue determines the nature of the fixed point. If the eigenvalues are complex, then the sign of the real part of each eigenvalue determines the nature of the fixed point.
\nIn this case, {naturetext}.
\n", "name": "Dynamical system 4", "parts": [{"prompt": "\nThe system can be written in the form $\\dot{\\boldsymbol{x}}=\\mathsf{A}\\boldsymbol{x}$, where $\\boldsymbol{x}=\\pmatrix{x,y}^\\mathsf{T}$.
\nIdentify the components of the matrix $\\mathsf{A}$.
\n \n$\\mathsf{A}=\\Bigg($ | \n[[0]] | \n[[1]] | \n$\\Bigg)$ | \n
[[2]] | \n[[3]] | \n
Calculate the trace $\\tau$, and the determinant $\\delta$ of the matrix $\\mathsf{A}$.
\nTrace $\\tau=$ [[0]].
\nDeterminant $\\delta=$ [[1]].
\n \n", "type": "gapfill", "scripts": {}, "showCorrectAnswer": true, "gaps": [{"showPrecisionHint": false, "type": "numberentry", "maxValue": "tau", "scripts": {}, "showCorrectAnswer": true, "marks": 1, "minValue": "tau"}, {"showPrecisionHint": false, "type": "numberentry", "maxValue": "delta", "scripts": {}, "showCorrectAnswer": true, "marks": 1, "minValue": "delta"}], "marks": 0}, {"prompt": "\nCalculate the eigenvalues $\\lambda_1$ and $\\lambda_2$ of the matrix $\\mathsf{A}$.
\nIf the eigenvalues have zero imaginary part, enter the eigenvalue with the largest real part first. If the eigenvalues have non-zero imaginary part, enter the eigenvalue with the largest imaginary part first.
\n$\\lambda_1=$ [[0]].
\n$\\lambda_2=$ [[1]].
\n \n", "type": "gapfill", "scripts": {}, "showCorrectAnswer": true, "gaps": [{"showpreview": true, "expectedvariablenames": [], "scripts": {}, "checkingaccuracy": 0.001, "showCorrectAnswer": true, "checkvariablenames": false, "vsetrangepoints": 5, "type": "jme", "vsetrange": [0, 1], "marks": 1, "answer": "{lam1}", "checkingtype": "absdiff"}, {"showpreview": true, "expectedvariablenames": [], "scripts": {}, "checkingaccuracy": 0.001, "showCorrectAnswer": true, "checkvariablenames": false, "vsetrangepoints": 5, "type": "jme", "vsetrange": [0, 1], "marks": 1, "answer": "{lam2}", "checkingtype": "absdiff"}], "marks": 0}, {"prompt": "\nAssuming that the $x$-component of each eigenvector is $1$, find the $y$-components of the eigenvectors corresponding to the eigenvalues $\\lambda_1$ and $\\lambda_2$.
\n$y$-component of eigenvector corresponding to $\\lambda_1$: [[0]].
\n$y$-component of eigenvector corresponding to $\\lambda_2$: [[1]].
\n \n", "type": "gapfill", "scripts": {}, "showCorrectAnswer": true, "gaps": [{"showpreview": true, "expectedvariablenames": [], "answersimplification": "all", "scripts": {}, "checkingaccuracy": 0.001, "showCorrectAnswer": true, "checkvariablenames": false, "vsetrangepoints": 5, "type": "jme", "vsetrange": [0, 1], "marks": 1, "answer": "{vec1}", "checkingtype": "absdiff"}, {"showpreview": true, "expectedvariablenames": [], "answersimplification": "all", "scripts": {}, "checkingaccuracy": 0.001, "showCorrectAnswer": true, "checkvariablenames": false, "vsetrangepoints": 5, "type": "jme", "vsetrange": [0, 1], "marks": 1, "answer": "{vec2}", "checkingtype": "absdiff"}], "marks": 0}, {"minAnswers": 0, "prompt": "Determine the nature of the fixed point at the origin.
", "distractors": ["", "", "", "", "", ""], "maxMarks": 0, "displayType": "radiogroup", "showCorrectAnswer": true, "type": "1_n_2", "shuffleChoices": false, "choices": ["{nature}
", "{natures[0]}
", "{natures[1]}
", "{natures[2]}
", "{natures[3]}
", "{natures[4]}
"], "displayColumns": 1, "minMarks": 0, "scripts": {}, "maxAnswers": 0, "matrix": [1, 0, 0, 0, 0, 0], "marks": 0}], "extensions": ["jsxgraph"], "tags": ["Differential equations", "centres", "differential equations", "dynamical system", "fixed points", "phase space", "spirals", "stable", "systems of differential equations", "unstable"], "statement": "\nConsider the two-dimensional dynamical system. Complex eigenvalues case , so centres or spirals.
\n\\[\\begin{align}\\dot{x}&=\\simplify[std]{{a}*x+{b}*y},\\\\\\dot{y}&=\\simplify[std]{{c}*x+{d}*y}.\\end{align}\\]
\n{ode1()}
\nThe above diagram shows the plot of $(x(t),y(t))$.
\nAt $t=0$ we have initally $x=-5,\\;\\;y=5$. Moving the point gives phase diagrams for the following initial values at $t=0$:
\n$x=\\;$ $y=\\;$
\nDotted lines give points at which $\\dot{x}=0,\\;\\dot{y}=0$.
\nThe plots below are for $x(t),\\;x(0)=-1$ and $y(t),\\;y(0)=1$, in black and red respectively where the horizontal axis is $t$.
\n{ode(xr,yr)}
\n", "type": "question", "variable_groups": [], "question_groups": [{"pickingStrategy": "all-ordered", "name": "", "questions": [], "pickQuestions": 0}], "functions": {"ode": {"type": "html", "language": "javascript", "parameters": [["xr", "number"], ["yr", "number"]], "definition": "\nvar a = Numbas.jme.unwrapValue(scope.variables.a);\nvar b = Numbas.jme.unwrapValue(scope.variables.b);\nvar c = Numbas.jme.unwrapValue(scope.variables.c);\nvar d = Numbas.jme.unwrapValue(scope.variables.d);\n\nfunction f(x,yy) {\n var y1 = yy[0];\n var y2 = yy[1];\n var z1 = a*y1+b*y2;\n var z2 = c*y1+d*y2;\n return [z1,z2];\n}\n\nvar div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{axis:true,showNavigation:true, boundingbox:[-xr,yr,xr,-yr]});\nvar brd=div.board;\n\nfunction ode() {\n return JXG.Math.Numerics.rungeKutta('heun', [1,-1], [0, 10], 200, f);\n}\nfunction ode1() {\n return JXG.Math.Numerics.rungeKutta('heun', [1,-1], [0, -10], 200, f);\n} \nvar g1 = brd.create('curve', [[0],[0]], {strokeColor:'red', strokeWidth:2, name:'y_1', withLabel:false});\nvar g2 = brd.create('curve', [[0],[0]], {strokeColor:'black', strokeWidth:2, name:'y_2', withLabel:false});\nvar data=ode();\nvar data1=ode1();\nvar l=data.length;\nvar l1=data1.length;\nvar h = 10/200;\ng1.updateDataArray = function() {\nthis.dataX = [];\nthis.dataY = [];\nfor(var i=0; i