// Numbas version: finer_feedback_settings {"name": "Dynamical system 6:Centre.", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {}, "ungrouped_variables": ["xr", "yr", "v", "f"], "name": "Dynamical system 6:Centre.", "tags": ["centres", "differential equations", "Differential equations", "dynamical system", "feedback", "fixed points", "interactive", "Jsxgraph", "jsxgraph", "navigation change", "phase space", "stable", "systems of differential equations", "unstable"], "preamble": {"css": "", "js": "var pc;\nvar brd;\nvar P1;\nvar brd1;\nvar g1;\nvar g2;\nvar fin;\nvar m;\nvar adv;\nfunction updateBoards(a,b,c,d) {\n function 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 \n function ode() {\n //solution curve data array produced in the interval between 0 and 10, 200 steps\n return JXG.Math.Numerics.rungeKutta('heun', [P1.Y(),P1.X()], [0, 10], 500, f);\n }\n function ode1() {\n //solution curve data array produced in the interval between 0 and -10, 200 steps\n return JXG.Math.Numerics.rungeKutta('heun', [P1.Y(),P1.X()], [0, -10], 500, f);\n }\n \n pc.updateDataArray = function() {\n var data = ode();\n var l=data.length;\n var data1=ode1();\n var l1=data1.length;\n this.dataX = [];\n this.dataY = [];\n for(var i=0; i0){\n ty='Unstable spiral.';\n } \n else if(ans1<0){\n ty='Stable spiral.';\n }\n else {\n ty='Centre.';\n }\n }\n else {\n if(det<0){\n ty='Saddle.';\n }\n else if ((det>0)&&(ans1>0)){\n ty='Unstable node.';\n } \n else {\n ty='Stable node.';\n }\n }\n }\n else {ty=''};\n //if either the input has not been completed or the correct answer has been input - no message.\n if(fin){adv='You have not entered all the numerical values into the matrix';}\n if(fin||((ans1==0)&&(ans2==0))){ m='';}\n //all entries have been input and an incorrect diagonal value has been input or gives the wrong eigenvalue.\n else if(ans1!=0){m='You did not enter the correct value for the diagonal.';}\n else {m='You have the wrong eigenvalue.';}\n \n var html = $(question.display.html);\n html.find('#type').text(ty);\n //This is displayed in the question as an aid to the user.\n html.find('#mess').text(m);\n \n /*values for hidden gapfills which are marked*/\n question.parts[0].gaps[3].display.studentAnswer(ans1); \n question.parts[0].gaps[4].display.studentAnswer(ans2);\n \n updateBoards(a,b,c,d);\n });\n});\n"}, "advice": "

Given the system of differential equations:

\n

\\[\\begin{align}\\dot{x}&=\\simplify[std]{a*x+b*y},\\\\\\dot{y}&=\\simplify[std]{c*x+d*y}.\\end{align}\\]

\n

It can be written in the form $\\dot{\\boldsymbol{x}}=\\mathsf{A}\\boldsymbol{x}$, where $\\boldsymbol{x}=\\pmatrix{x,y}^\\mathsf{T}$ and 

\n

\\[\\mathsf{A}=\\pmatrix{a& b\\\\c & d}\\]

\n

In this case, with $a=\\var{f}$  we want to enter values for $b,\\;c,\\;d$ such that the system gives a centre.

\n

For this to happen we need the eigenvalues of $A$ to be purely imaginary and you are given that they are $\\simplify{{v}*i}$ and $\\simplify{{-v}*i}$.

\n

The characteristic polynomial for $A$ is given by 

\n

\\[\\det\\left(\\mathsf{A}-\\lambda\\mathsf{I}\\right)=0,\\]

\n

i.e.  $(a-\\lambda)(d-\\lambda)-bc=0$.  This leads to $\\lambda^2-(a+d)\\lambda+(ad-bc)=0$.

\n

So in order to get purely imaginary eigenvalues $\\pm \\var{abs(v)*i}$ we need :

\n

1. $a+d=0 \\Rightarrow d=\\var{-f}$ as $a=\\var{f}$.

\n

2. $ad-bc=\\var{v^2} \\Rightarrow bc=-\\var{v^2}-\\var{f^2}$.

\n

Hence if you set $d=\\var{-f}$ and you  choose values of  $b,\\;c$ such that $bc=-\\var{f^2+v^2}$, this will give the required system of differential equations with phase space a centre and the required eigenvalues.

", "rulesets": {"std": ["all", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"stepsPenalty": 0, "prompt": "

The system can be written in the form $\\dot{\\boldsymbol{x}}=\\mathsf{A}\\boldsymbol{x}$, where $\\boldsymbol{x}=\\pmatrix{x,y}^\\mathsf{T}$.

\n

Input the components of the matrix $\\mathsf{A}$ in order to obtain a centre where the eigenvalues of $A$ are $\\simplify{{v}*i}$ and $\\simplify{{-v}*i}$.

\n

You are given that $a=\\var{f}$.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\mathsf{A}=\\Bigg($$\\var{f}$[[0]]$\\Bigg)$
[[1]][[2]]
\n

\n

\n

Once you have input appropriate values into the matrix, the diagram below shows the plot of $(x(t),y(t))$.

\n

At $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=\\;$

\n

\n

\n
\n

\n\n

\n

You can click on Steps to see the solutions for $x(t),\\;y(t)$ after you have input values into the matrix.

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "steps": [{"prompt": "

Graph of $x(t),\\;y(t)$

\n
\n

\n

$x(t)$ is in black, $y(t)$ in blue.

\n

You can use the navigation bar to zoom in and out of the graph.

", "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "information"}], "gaps": [{"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "1", "minValue": "1", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": false, "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthis.answered=true;"}}, "marks": 0, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 1, "type": "numberentry", "showPrecisionHint": false}, {"allowFractions": false, "variableReplacements": [], "maxValue": "0", "minValue": "0", "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "showCorrectAnswer": true, "scripts": {}, "marks": 2, "type": "numberentry", "showPrecisionHint": false}], "showCorrectAnswer": true, "scripts": {}, "marks": 0, "type": "gapfill"}], "statement": "

Consider the following two-dimensional dynamical system . You have to find values for $a,\\;b\\;c,\\;d$ such that the system's phase space is a centre.

\n

\\[\\begin{align}\\dot{x}&=\\simplify[std]{a*x+b*y},\\\\\\dot{y}&=\\simplify[std]{c*x+d*y}.\\end{align}\\]

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "variables": {"xr": {"definition": "50", "templateType": "anything", "group": "Ungrouped variables", "name": "xr", "description": ""}, "yr": {"definition": "50", "templateType": "anything", "group": "Ungrouped variables", "name": "yr", "description": ""}, "f": {"definition": "random(-9..9 except[0,1,-1])", "templateType": "anything", "group": "Ungrouped variables", "name": "f", "description": ""}, "v": {"definition": "random(1..5)", "templateType": "anything", "group": "Ungrouped variables", "name": "v", "description": ""}}, "metadata": {"notes": "

\n

01/04/2014:

\n

Created.

\n

02/02/2014:

\n

Graphs of  x(t), y(t) included.

\n

04/08/2014

\n

Changed showNavigation to false and commented out line re using Jsxgraph navigation in the Part as this does not work at present - need to upload new version of jsxgraph?

", "description": "

Asking users to input coefficients of a system of diff equations so that the phase space is a centre. All systems input by the user are graphed together with immediate feedback. Also included in the Steps are the graphs of the solutions for $x(t),\\; y(t);\\; x(0)=-5,\\;y(0)=5.$

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "showQuestionGroupNames": false, "question_groups": [{"name": "", "pickingStrategy": "all-ordered", "pickQuestions": 0, "questions": []}], "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}]}], "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}]}