// Numbas version: finer_feedback_settings {"name": "Dynamical system 9: Saddle.", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"functions": {}, "parts": [{"stepsPenalty": 0, "showCorrectAnswer": true, "variableReplacements": [], "showFeedbackIcon": true, "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 saddle.

\n

In order to achieve this you have to supply the diagonal elements of the matrix, the entries for $b,\\;c$ are given. In this case the eigenvalues of $A$ are real and of opposite signs. 

\n

You are given that $b=\\var{f},\\;c=\\var{g}$.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$\\mathsf{A}=\\Bigg($[[0]]$\\var{f}$$\\Bigg)$
$\\var{g}$[[1]]
\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.

", "type": "gapfill", "gaps": [{"showFeedbackIcon": true, "minValue": "1", "type": "numberentry", "allowFractions": false, "maxValue": "1", "showCorrectAnswer": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain", "variableReplacements": [], "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "scripts": {"mark": {"script": "!doesMarking;\nthis.answered=true;", "order": "instead"}}, "marks": 0}, {"showFeedbackIcon": true, "minValue": "1", "type": "numberentry", "allowFractions": false, "maxValue": "1", "showCorrectAnswer": false, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain", "variableReplacements": [], "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "scripts": {"mark": {"script": "!doesMarking;\nthis.answered=true;", "order": "instead"}}, "marks": 0}, {"showFeedbackIcon": true, "minValue": "1", "type": "numberentry", "allowFractions": false, "maxValue": "1", "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain", "variableReplacements": [], "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "scripts": {}, "marks": 1}, {"showFeedbackIcon": true, "minValue": "1", "type": "numberentry", "allowFractions": false, "maxValue": "1", "showCorrectAnswer": true, "notationStyles": ["plain", "en", "si-en"], "correctAnswerStyle": "plain", "variableReplacements": [], "correctAnswerFraction": false, "variableReplacementStrategy": "originalfirst", "scripts": {}, "marks": 2}], "steps": [{"showCorrectAnswer": true, "variableReplacements": [], "showFeedbackIcon": true, "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.

", "type": "information", "variableReplacementStrategy": "originalfirst", "scripts": {}, "marks": 0}], "variableReplacementStrategy": "originalfirst", "scripts": {}, "marks": 0}], "variablesTest": {"maxRuns": 100, "condition": ""}, "extensions": ["jsxgraph"], "metadata": {"description": "

Asking users to input coefficients of a system of diff equations so that the phase space is a saddle. 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"}, "rulesets": {"std": ["all", "!collectNumbers", "!noLeadingMinus"]}, "ungrouped_variables": ["xr", "yr", "g", "f"], "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 saddle.

\n

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

\n

Note that this question is purely formative and for experimenting with. No marks are given.

", "preamble": {"css": "", "js": "var pc;\nvar brd;\nvar P1;\nvar brd1;\nvar g1;\nvar g2;\nvar fin;\nvar m;\nvar e1;\nvar e2;\n\nfunction updateBoards(a,b,c,d,r1,r2) {\n function f(x,yy) {\nvar y1 = yy[0];\nvar y2 = yy[1];\nvar z1 = a*y1+b*y2;\nvar z2 = c*y1+d*y2;\nreturn [z1,z2];\n }\n \n function ode() {\n//solution curve data array produced in the interval between 0 and 10, 200 steps\nreturn 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\nreturn JXG.Math.Numerics.rungeKutta('heun', [P1.Y(),P1.X()], [0, -10], 500, f);\n }\n\npc.updateDataArray = function() {\nvar data = ode();\nvar l=data.length;\nvar data1=ode1();\nvar l1=data1.length;\nthis.dataX = [];\nthis.dataY = [];\nfor(var i=0; i0)&&(str<0)){ans=1;} else {ans=0;};\n//Feedback to user if the diagonal element is not correct once all numbers have been input.\nfin=isNaN(a)||isNaN(d);\nif(!fin){\n if(t1<0){\n if(ans1>0){ty='Unstable spiral.';} \n else if(ans1<0){ty='Stable spiral.';} else {ty='Centre.';}}\n else {if(det<0){ty='Saddle.';}\n else if ((det>0)&&(ans1>0)){ty='Unstable node.';} else {ty='Stable node.';}}}\nelse {ty=''};\n//if either the input has not been completed or the correct answer has been input - no message.\nif(fin||(ans==1)){ m='';}\n//all entries have been input and an incorrect diagonal value has been input or gives the wrong eigenvalue.\n else if(st1==-1){m='The eigenvalues are complex, so you do not have a saddle.';}\n else {m='This is not a saddle.';}\n\nhtml.find('#type').text(ty);\n//This is displayed in the question as an aid to the user.\nhtml.find('#mess').text(m);\n\n/*values for hidden gapfills which are marked*/\nquestion.parts[0].gaps[2].display.studentAnswer(st1); \nquestion.parts[0].gaps[3].display.studentAnswer(ans);\n\nupdateBoards(a,b,c,d,r1,r2);\n});\n});\n"}, "variable_groups": [], "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 $b=\\var{f},\\;c=\\var{g}$  we want to enter values for $a,\\;d$ such that the system gives a saddle for its phase space.

\n

For this to happen we need the eigenvalues of $A$ to be real with one positive and one negative.

\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 real eigenvalues with opposite signs we need :

\n

1. Real roots. $(a+d)^2 \\gt 4(ad-bc) \\Rightarrow (a-d)^2 \\gt -4bc$. 

\n

Hence we have one condition is that $(a-d)^2 \\gt \\simplify[all,!collectNumbers]{-4*{f}*{g}={-4*f*g}}$

\n

2. Opposite signs. The roots are given by $\\displaystyle \\frac{(a+d) \\pm \\sqrt{(a+d)^2-4(ad-bc)}}{2}$.

\n

Hence if $\\operatorname{det}(A)=ad-bc \\lt 0$ we see that the roots are opposite in sign.

\n

So this is the other condition: $ad-bc \\lt 0 \\Rightarrow ad \\lt \\var{f}\\times \\var{g}=\\var{f*g}$

\n

", "variables": {"yr": {"description": "", "group": "Ungrouped variables", "definition": "50", "templateType": "anything", "name": "yr"}, "g": {"description": "", "group": "Ungrouped variables", "definition": "-sign(f)*random(1..5)", "templateType": "anything", "name": "g"}, "f": {"description": "", "group": "Ungrouped variables", "definition": "random(-9..9 except[0,1,-1])", "templateType": "anything", "name": "f"}, "xr": {"description": "", "group": "Ungrouped variables", "definition": "50", "templateType": "anything", "name": "xr"}}, "tags": ["centres", "Differential equations", "differential equations", "dynamical system", "feedback", "fixed points", "interactive", "Jsxgraph", "jsxgraph", "phase space", "saddle", "stable", "systems of differential equations", "unstable"], "name": "Dynamical system 9: Saddle.", "type": "question", "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/"}]}