︠b84db3fa-ea53-42e5-b316-3e3e37a7c053s︠ # This worksheet was converted from a notebook running Jupyter kernel # version sage-9.2. ︡8f36afba-f6ae-4583-9f55-8ebe3af0c4d5︡{"done":true} ︠7996e6cf-6905-461c-9682-ba70054c9455︠ # This is a comment # Declare variable var('x') # Could also use: x = var('x') assume(x>0) # PDF f(x) = 1/30*exp(-x/30) f(x) ︡a2872234-2bac-4767-a3b6-ed09f37c8906︡{"stdout":"x\n"}︡{"stdout":"1/30*e^(-1/30*x)\n"}︡{"done":true} ︠066396e6-1984-4f15-a2d6-a3f6ff6daaa8s︠ # Show area under curve is 1 integral(f(x),x,0,infinity) ︡ad119a1f-edd0-4601-a5d8-b365f45880ad︡{"stdout":"1"}︡{"stdout":"\n"}︡{"done":true} ︠1d09fed1-fa7f-4533-888e-33adaea2f647s︠ plot(f(x),0,140) ︡e6f238b8-6e03-41c3-83ec-ac5acf69b806︡{"file":{"filename":"/home/user/.sage/temp/project-93e0cca5-bc94-466b-a4d0-f10b341c789c/1475/tmp_nqfoahdu.svg","show":true,"text":null,"uuid":"e0799f5f-ef96-4b25-b96a-ec2ccbe97f5d"},"once":false}︡{"done":true} ︠6afb1f00-6453-4c52-99c6-047c9a46b9c2︠ # Find P(X > 30) integral(f(x),x,30,infinity) ︡ba369084-d0b7-4d3d-94a2-3613e972a4e6︡{"stdout": "e^(-1)", "done": true}︡ ︠44e3155f-bff2-4a57-82b3-9e7898d70924︠ prob = integral(f(x),x,30,infinity) prob ︡7f552ee3-49ec-413d-b3b8-671257365913︡{"stdout":"0.367879441171442\n"}︡{"done":true}︡ ︠2c36f747-5c5a-442f-ae8f-9087ccb8a983︠ # Evaluate numerically n(prob,digits = 4) ︡95ded5d8-7546-4fe3-89ca-c05512932ca1︡{"stdout": "0.3679", "done": true}︡ ︠5436bc63-f4de-4a6a-9a5e-5d5575d53a2c︠ # Different syntax - put function after dot prob.n(digits = 4) prob ︡9414973a-f740-4c4f-863c-03e68bcfb2aa︡{"stdout": "0.3679", "done": true}︡ ︠d193e3a9-36aa-4068-98d7-fb55a2c87a48︠ round(prob, 4) ︡09ea7f5b-12a9-4315-89ab-a58fd22e83d9︡{"stdout": "0.3679", "done": true}︡ ︠ddb27973-9449-46e1-aed1-c9ba2c0c72b6s︠ # Find root of equation var('c') assume(c>0) eq = 0.95 - integral(f(x),x,0,c) find_root(eq, 0, 300) ︡42d33645-c44d-4b51-ace8-4429da8ea616︡{"stdout":"c\n"}︡{"stdout":"89.8719682066197"}︡{"stdout":"\n"}︡{"done":true} ︠53b942ca-47c8-4eb7-bbbd-99ad4be37c13︠ # CDF F(x) = integral(f(x),x,0,x) F(x) ︡853f3171-d261-4d31-9afc-9fd1811880f8︡{"stdout": "-e^(-1/30*x) + 1", "done": true}︡ ︠30d072bd-c389-4ac6-987c-c501ac0a239b︠ # PDF diff(F(x),x) ︡f24582c3-9473-4161-a886-b4ce17ad8f50︡{"stdout": "1/30*e^(-1/30*x)", "done": true}︡ ︠e2db3257-a9bc-4ffa-bf13-aa09f44404f8s︠ # Show help integrate? ︡56cedcdb-99bf-4757-9f4d-a20c0ea50bc4︡{"code":{"filename":null,"lineno":-1,"mode":"text/x-rst","source":"File: /ext/sage/sage-9.2/local/lib/python3.8/site-packages/sage/misc/functional.py\nSignature : integrate(x, *args, **kwds)\nDocstring :\nReturn an indefinite or definite integral of an object \"x\".\n\nFirst call \"x.integral()\" and if that fails make an object and\nintegrate it using Maxima, maple, etc, as specified by algorithm.\n\nFor symbolic expression calls \"sage.calculus.calculus.integral()\" -\nsee this function for available options.\n\nEXAMPLES:\n\n sage: f = cyclotomic_polynomial(10)\n sage: integral(f)\n 1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + x\n\n sage: integral(sin(x),x)\n -cos(x)\n\n sage: y = var('y')\n sage: integral(sin(x),y)\n y*sin(x)\n\n sage: integral(sin(x), x, 0, pi/2)\n 1\n sage: sin(x).integral(x, 0,pi/2)\n 1\n sage: integral(exp(-x), (x, 1, oo))\n e^(-1)\n\nNumerical approximation:\n\n sage: h = integral(tan(x)/x, (x, 1, pi/3)); h\n integrate(tan(x)/x, x, 1, 1/3*pi)\n sage: h.n()\n 0.07571599101...\n\nSpecific algorithm can be used for integration:\n\n sage: integral(sin(x)^2, x, algorithm='maxima')\n 1/2*x - 1/4*sin(2*x)\n sage: integral(sin(x)^2, x, algorithm='sympy')\n -1/2*cos(x)*sin(x) + 1/2*x"}}︡{"done":true} ︠b99c830e-87f4-4efa-b357-0915585c930ds︠ # Simple math can be done too! 2+2 ︡c1b91957-5e20-493a-a4e7-eecb1ca7f1e5︡{"stdout":"4\n"}︡{"done":true}