︠5657454d-610d-4eca-975b-feb8a391143cis︠ %md

This is a sage worksheet.

I have added this text by using the "markdown" indicator at the start of this command. Sage knows html and latex, so I can adopt a literate programming style, mixing text, equations like $y = \frac{x}{x-1}$, and commands -- as you can with for-purchase Computer Math Systems. To see what I really typed here, double click on this text! To re-execute, highlight the command and press shift-return. ︡912010a3-cb1a-43d7-9f82-81c84950015a︡{"md":"\n

This is a sage worksheet.

\n \n\nI have added this text by using the \"markdown\" indicator at the start of this command. Sage knows html and latex, so I can adopt a literate programming style, mixing text, equations like $y = \\frac{x}{x-1}$, and commands -- as you can with for-purchase Computer Math Systems. To see what I really typed here, double click on this text! To re-execute, highlight the command and press shift-return.\n"}︡ ︠8a9c6d0b-924e-4264-9b5c-3ae4684bea4ei︠ %md Below are some commands that illustrate the similarities to Maple/Mathematica. You simply click on the command and then shift-return to execute the command. Notice also that once you execute a command you are moved to the next one -- or if you execute the last command, you will be moved to a blank line. ︡a40b0352-77a6-4712-9a08-6999ab4bf2c8︡{"md":"Below are some commands that illustrate the similarities to Maple/Mathematica. You simply click on the command and then shift-return to execute the command.\n\nNotice also that once you execute a command you are moved to the next one -- or if you execute the last command, you will be moved to a blank line.\n"}︡ ︠0849b182-e0de-4aed-9b8a-580e488f6b05︠ ︠1e667025-b663-4207-b040-0179e25c5f0a︠ ︠09e9161b-febd-4776-8b5a-4546a58d4f74︠ 5 + 6 - sin(4).n() ︠7bf72f2a-e8f6-4ce2-8bc9-1ea101d1a016︠ 5+6-sin(4.0) #show n() and .n() sin() is an object and you can attach a method to it... sin(4).n() ︠0d49a4fd-3bbd-45b5-b642-12beb7a31b3f︠ ︠a1ef59cd-3574-47b7-b734-d2fb938feb85︠ f(x)=x^2 - 3*x + 2 # show f. ︠4e9fa447-3430-4fe3-961d-761544e0f127︠ show(f) ︠73ae5254-1033-4373-a386-0e71087beac5︠ f.abs ︠6b8b5ced-9ec1-4327-946c-ee7d9aaeb84d︠ limit(f(x), x=2) ︠adac7989-db22-43e1-9e22-8a4e5e5178b1︠ diff(f(x), x) ︠d7aa22b0-27d6-4e81-9e33-cf87af6c391a︠ integrate(f(x), x) ︠7d9589e5-3ef7-4eeb-82e8-f2cd572fecdd︠ plot(f(x), -10, 10, ymin=-2, ymax=2) #show ymin and ymax ︠f4ec06d4-c728-4732-a5f0-cc9a19f04ef2︠ find_root(f(x), -10, 10) ︠8f95b209-c8ac-4755-beb3-3ce22b90e7f2︠ factor(f(x)) ︠c1c9c99a-2ec6-43dc-ba01-b1cbad8fbec0︠ solve(f(x)==0, x) ︠0ae00f79-826a-41fa-891d-ada60ecc5da8︠ var('v') solve(v^2 - 2*v +2 == 0, v) # show how to add a new executable and do this one...show var('v') and del(v) ︠f02d19fc-f627-4d77-9c21-f7a2130bf53bi︠ %md Sage has matlab-like functionality as well... ︡12442600-93f1-4d7a-97b3-e94138a9a41f︡{"md":"Sage has matlab-like functionality as well...\n"}︡ ︠f3ef318b-0fd1-4479-a073-7854f41aaf0a︠ u = vector([1, 3/2, 2, 4]) v = vector([-2, 1, 2, 3]) #show u. ︠02df304e-0139-4337-aec1-45a92e585444︠ 2*u - 3*v ︠726c1ac6-fe8b-440f-a704-41d3240034d1︠ u[0] ︠a37c5f7c-ee92-4d97-9142-0ddc89b3aeff︠ u.dot_product(v) u.norm() ︠e50306a8-0264-4ae5-a26a-dfdadc4fd590︠ ︠6714a54a-7711-4bae-be42-46ec2d245cf0︠ A = matrix([[1, 2, 3], [4, 5, 6], [9, 8, 7]]) ︡781c5e10-6828-4112-9bb6-1effdff1982f︡ ︠a71e1392-70f4-48c2-adad-6e13c8401f62︠ ︠cd4940ad-c002-4850-9914-70caf7c1eba5︠ show(A) ︠7f9daff0-7b9a-47eb-89ce-f907df08806d︠ A. transpose() ︠ca2dbc1a-ded2-4f9a-8eb5-d957c5a30f47︠ A.echelon_form() ︠c5ee7f2b-6191-49e3-9e52-0da1d72cafbe︠ A^-1 ︠85a65630-6899-4c65-bae9-54e962ebe617i︠ %md The Python Programming Environment is available as well. Here is a simple version of Newton's Method built as a function to call... ︡88cd6b40-e101-4aaa-bc77-c3e21fe250c2︡{"md":"\nThe Python Programming Environment is available as well. Here is a simple version of Newton's Method built as a function to call...\n\n"}︡ ︠2f65c510-b712-43c4-8d13-c6cd5a51ba4a︠ ︠c8c45ae1-afa6-4ef4-9e68-b17beee71ba6︠ def Newton(f, x0): g(x) = x - f(x) / diff (f(x), x) #this is cheating, since I used the symbolic derivative... k = 0 xold = x0 xnew = g(x0) print k, xold while abs(xold - xnew) > 10E-12 and k < 10: xold = xnew xnew = g(xold) k += 1 print k, xnew ︡9163778d-9bdb-41d0-816e-c68f6ad9cc96︡ ︠6ff8ec96-bff6-4b34-88e3-e6c6317e7fdai︠ %md Now let's call the function: ︡deb95420-79eb-4b35-a053-9cf702673406︡{"md":"Now let's call the function:\n"}︡ ︠8b199575-55fd-4711-bd78-8c9b548fc955︠ w(x) = cos(x) - x^2 Newton(lambda x: w, 2.0) #demonstrate show! ︠d1db8146-4e9e-4bbf-8e0f-18fab774698ci︠ %md You can also access R (another freely available environment used mainly by statisticians) from within Sage; essentially you are passing information to the r interpreter... ︠4f547b09-074e-4be5-960d-2ec30f5f18a2i︠ %md Also built in to Sage is the programming language R ︡f839b362-d3fa-4f94-8670-d3870b583f50︡{"md":"Also built in to Sage is the programming language R\n"}︡ ︠99bc19a5-7a46-42c3-908a-e5693124f0cb︠ r.summary(r.c(1,2,3,111,2,3,2,3,2,5,4)) ︠7a375506-3adb-466a-849d-653ee5f94118i︠ %md More plotting... ︡fb651518-df3d-4089-93cc-188ec3512643︡{"md":"\nMore plotting...\n"}︡ ︠8b492f52-71be-4c76-a626-e6c54a30f700︠ #You can also combine plots by adding them. This allows us to make each plot a different color. plot(x^2, (x, 0, pi),color='red')+plot(sqrt(x), (x, 0, pi),color='green')+plot(sin(x), (x, 0, pi)) ︠48855b83-2380-4d93-b901-a5434b20824d︠ plot3d? ︠57c28646-8853-4fee-9642-9449c14f28e1︠ sombrero(x,y) = cos(sqrt(x^2 + y^2)) plot3d(sombrero, (x, -5, 5), (y, -5, 5)) ︠5cd81fbc-e63b-45f6-998f-4dd2375c4ba4︠ z = sqrt(-1) print z, z^2, z^3, z^4 print z + 2*z^2 + 3*z^3 + 4*z^4 ︠06ae26eb-7d31-4bed-b12c-477cd1ea9a4fi︠ %md

http://sagemath.org/
http://wiki.sagemath.org/quickref

︡ff748b31-d55f-431b-b3d4-42c61768c87c︡{"md":"

\nhttp://sagemath.org/\n
\nhttp://wiki.sagemath.org/quickref\n

\n"}︡ ︠d425cb3a-2daa-49e1-8f7e-b06ac32114a9︠