// Numbas version: exam_results_page_options {"name": "SageMath Cell", "extensions": ["sagemath-cell"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"advice": "", "functions": {}, "variablesTest": {"maxRuns": 100, "condition": ""}, "name": "SageMath Cell", "parts": [{"useCustomName": true, "customName": "Contour plot", "variableReplacements": [], "showFeedbackIcon": true, "marks": 0, "showCorrectAnswer": true, "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "variableReplacementStrategy": "originalfirst", "scripts": {}, "prompt": "

Let \\(f\\) be the function corresponding to the following contour plot:

\n

{sagecell(plot_code, [\"autoeval\": true, \"hide\": [\"editor\", \"language\", \"evalButton\", \"permalink\"]])}

", "type": "information"}, {"useCustomName": true, "customName": "Sphere-plane intersection", "variableReplacements": [], "showFeedbackIcon": true, "marks": 0, "showCorrectAnswer": true, "adaptiveMarkingPenalty": 0, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "variableReplacementStrategy": "originalfirst", "scripts": {}, "prompt": "

Let \\(f(x,y,z)=2xy+z^2\\), let \\(S_1\\) and \\(S_2\\) be, respectively, the sphere \\(x^2 + y^2 + z^2=6\\) and the plane \\(x+y+z=0\\), let \\(C\\) be the intersection curve of \\(S_1\\) and \\(S_2\\), and let \\(Q\\) be the solid inside \\(S_1\\) and above \\(S_2\\).

\n

Consider the following SageMath cell:

\n

{sagecell(curve_code, [\"hide\": [\"permalink\"]])}

", "type": "information"}], "metadata": {"description": "

Uses an extension to embed SageMath cells into content areas.

", "licence": "Creative Commons Attribution 4.0 International"}, "variable_groups": [], "extensions": ["sagemath-cell"], "rulesets": {}, "ungrouped_variables": ["plot_code", "curve_code"], "preamble": {"css": "", "js": ""}, "statement": "", "tags": [], "variables": {"plot_code": {"templateType": "anything", "description": "", "name": "plot_code", "group": "Ungrouped variables", "definition": "safe(\"\"\"\nvar(\"x,y\")\nf(x,y) = 15*(4*x+3*y^2)/(x^2+y^2+4)^2\ncurvas_nivel = contour_plot(f(x,y), (x,-4,4), (y,-4,4), contours=25, cmap=\"jet\", colorbar=True)\nx0 = (-3,1)\npunto = point(x0,color=\"black\",size=40,zorder=3)\nu = (-4/5,3/5)\nv = (1/sqrt(5),-2/sqrt(5))\nvec_u = arrow(x0,vector(x0)+vector(u),color=\"red\")\nvec_v = arrow(x0,vector(x0)+vector(v),color=\"green\")\nshow(curvas_nivel + vec_u + vec_v + punto, figsize=5)\n\"\"\")"}, "curve_code": {"templateType": "anything", "description": "", "name": "curve_code", "group": "Ungrouped variables", "definition": "safe(\"\"\"\nvar(\"x,y,z,lambda_1,lambda_2\")\nf(x,y,z) = 2*x*y + z^2\nG_1(x,y,z) = x^2 + y^2 + z^2 - 6\nG_2(x,y,z) = x + y + z\ngrad_f = diff(f)\ngrad_G_1 = diff(G_1)\ngrad_G_2 = diff(G_2)\n\nsystem = [grad_f(x,y,z)[i] == \n lambda_1*grad_G_1(x,y,z)[i] + lambda_2*grad_G_2(x,y,z)[i] \n for i in [0,1,2]]\nsystem.append(G_1(x,y,z)==0)\nsystem.append(G_2(x,y,z)==0)\nsolutions = solve(system, x, y, z, lambda_1, lambda_2)\nfor sol in solutions:\n print sol, \"f(x,y,z)=\", f(x,y,z).subs(sol)\n\"\"\")"}}, "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}]}