// Numbas version: finer_feedback_settings {"name": "Dynamical system 7: Stable spiral.", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"tags": ["centres", "differential equations", "Differential equations", "dynamical system", "feedback", "fixed points", "interactive", "JSXgraph", "Jsxgraph", "jsxgraph", "phase space", "stable", "systems of differential equations", "unstable"], "parts": [{"marks": 0, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "gaps": [{"marks": 0, "notationStyles": ["plain", "en", "si-en"], "minValue": "1", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": false, "correctAnswerFraction": false, "correctAnswerStyle": "plain", "allowFractions": false, "variableReplacements": [], "type": "numberentry", "showFeedbackIcon": true, "maxValue": "1"}, {"marks": 0, "notationStyles": ["plain", "en", "si-en"], "minValue": "1", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": false, "correctAnswerFraction": false, "correctAnswerStyle": "plain", "allowFractions": false, "variableReplacements": [], "type": "numberentry", "showFeedbackIcon": true, "maxValue": "1"}, {"marks": 1, "notationStyles": ["plain", "en", "si-en"], "minValue": "-1", "scripts": {}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "correctAnswerFraction": false, "correctAnswerStyle": "plain", "allowFractions": false, "variableReplacements": [], "type": "numberentry", "showFeedbackIcon": true, "maxValue": "-1"}, {"marks": 2, "notationStyles": ["plain", "en", "si-en"], "minValue": "1", "scripts": {"mark": {"order": "instead", "script": "!doesMarking;\nthisAnswered=true;"}}, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "correctAnswerFraction": false, "correctAnswerStyle": "plain", "allowFractions": false, "variableReplacements": [], "type": "numberentry", "showFeedbackIcon": true, "maxValue": "1"}], "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}$.
\nInput the components of the matrix $\\mathsf{A}$ in order to obtain a stable spiral.
\nIn 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 complex and of the form $w+vi,\\;w-vi$ where $w <0$.
\nYou are given that $b=\\var{f},\\;c=\\var{g}$.
\n$\\mathsf{A}=\\Bigg($ | \n[[0]] | \n$\\var{f}$ | \n$\\Bigg)$ | \n
$\\var{g}$ | \n[[1]] | \n
Once you have input appropriate values into the matrix, the diagram below 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=\\;$
\n\n\n\n\n\n\nYou can click on Steps to see the solutions for $x(t),\\;y(t)$ after you have input values into the matrix.
", "variableReplacements": [], "scripts": {}, "type": "gapfill", "showFeedbackIcon": true, "steps": [{"marks": 0, "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "prompt": "\n
$x(t)$ is in black, $y(t)$ in blue.
\nYou can use the navigation bar to zoom in and out of the graph.
", "variableReplacements": [], "scripts": {}, "type": "information", "showFeedbackIcon": true}]}], "metadata": {"description": "Asking users to input coefficients of a system of diff equations so that the phase space is a stable spiral. 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"}, "extensions": ["jsxgraph"], "variablesTest": {"condition": "", "maxRuns": 100}, "functions": {}, "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 stable spiral.
\n\\[\\begin{align}\\dot{x}&=\\simplify[std]{a*x+b*y},\\\\\\dot{y}&=\\simplify[std]{c*x+d*y}.\\end{align}\\]
\nNote that this question is purely formative and for experimenting with. No marks are given.
", "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}\\]
\nIt 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}\\]
\nIn this case, with $b=\\var{f},\\;c=\\var{g}$ we want to enter values for $a,\\;d$ such that the system gives a stable spiral for its phase space.
\nFor this to happen we need the eigenvalues of $A$ to be complex with negative real parts.
\nThe characteristic polynomial for $A$ is given by
\n\\[\\det\\left(\\mathsf{A}-\\lambda\\mathsf{I}\\right)=0,\\]
\ni.e. $(a-\\lambda)(d-\\lambda)-bc=0$. This leads to $\\lambda^2-(a+d)\\lambda+(ad-bc)=0$.
\nSo in order to get complex eigenvalues with negative real parts we need :
\n1. Complex roots. Hence $(a+d)^2 \\lt 4(ad-bc) \\Rightarrow (a-d)^2 \\lt -4bc$. Note that this means that $b,\\;c$ must have opposite signs as they do have for this example.
\nHence we have one condition is that $(a-d)^2 \\lt \\simplify[all,!collectNumbers]{-4*{f}*{g}={-4*f*g}}$
\n2. Real part $\\lt 0$ gives the other condition $a+d \\lt 0$.
\n", "preamble": {"js": "var pc;\nvar brd;\nvar P1;\nvar brd1;\nvar g1;\nvar g2;\nvar fin;\nvar m;\nfunction updateBoards(a,b,c,d) {\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; i