Tutorial: Calculus system:sage
Use the var command to define some symbolic variables. You can separate the variables by commas or spaces in the var command.
{{{id=5| var('x y z epsilon') /// (x, y, z, epsilon) }}} {{{id=6| cos(x^3) - y^2*z + epsilon /// -y^2*z + cos(x^3) + epsilon }}} {{{id=7| /// }}} {{{id=0| /// }}}Problem: Create the following expressions: $\sin^5(x)\cos^2(x), \qquad \displaystyle \frac{x^3}{x^3 + 1}, \qquad k\cdot P \cdot \left(1 - \frac{P}{K}\right)$.
Note that you must put in an asterisk (*) for multiplication.
{{{id=20| /// }}} {{{id=19| /// }}} {{{id=11| /// }}} {{{id=10| /// }}}Most standard functions are defined in Sage. They are named lowercase, much like in Maple. E.g.,
sin, cos, tan, sec, csc, cot, sinh, cosh, tanh, sech, csch, coth, log, exp, etc.
{{{id=8| var('x,y') sin(x) + cos(y) - tan(x/y) + sec(x*csc(y))^3 /// sec(x*csc(y))^3 + cos(y) - tan(x/y) + sin(x) }}} {{{id=2| /// }}}Problem: Construct the symbolic expresion $\sin(x^{\cos(y)} + \theta) + \coth(2x) + \log(3x)\cdot \exp(y^3)$.
{{{id=17| /// }}} {{{id=26| /// }}}Use the subs method to replace any variables by other variables.
{{{id=29| var('x,y') f = sin(x) + cos(y) - x^2 + y /// }}} {{{id=28| f.subs(x=5) /// cos(y) + y + sin(5) - 25 }}} {{{id=25| f.subs(x=y, y=x) /// sin(y) - y^2 + cos(x) + x }}} {{{id=31| /// }}}Problem: Replace $x$ by $\sin(y)-x$ in the expression $x^3 + x y$.
{{{id=32| /// }}} {{{id=35| /// }}}To expand a symbolic expression with exponents, use the expand method.
{{{id=34| var('x,y') f = (x+2*y)^3 f /// (2*y + x)^3 }}} {{{id=30| f.expand().show() # tip -- using show makes the output nicer ///Problem: Expand the expression $(2\sin(x) - \cos(y))^5$.
{{{id=37| /// }}} {{{id=16| /// }}} {{{id=15| /// }}}To create a symbolic function, use the notation f(x,y) = x^3 + y.
{{{id=13| f(x,y) = x^3 + y f /// (x, y) |--> y + x^3 }}} {{{id=9| f(2,3) /// 11 }}} {{{id=21| f(pi,e) /// pi^3 + e }}} {{{id=22| /// }}} {{{id=23| /// }}} {{{id=24| /// }}}