Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168727
Image: ubuntu2004
x=var('x') solve(x^2-2*x+1,x)
[x == 1]
x=var('x') solve(x^2-2/x+1,x)
[x == -1/2*I*sqrt(7) - 1/2, x == 1/2*I*sqrt(7) - 1/2, x == 1]
a,b,c,d=var('a b c d') solve([d^2+b*a+c-sqrt(a)==0],d)
[d == -sqrt(-a*b - c + sqrt(a)), d == sqrt(-a*b - c + sqrt(a))]
x, y ,z= var('x,y,z') solve([x+y+z==6, x-y==4 ,x+z==9], x, y,z)
[[x == 1, y == -3, z == 8]]
theta = var('theta') solve(cos(theta)==sin(theta), theta)
theta = var('theta') find_root(cos(theta)==sin(theta),0,pi)
0.78539816339744839
pi/0.78539816339744839
1.273239544735163*pi
f = 1/(x^2-1) f.partial_fraction(x)
1/2/(x - 1) - 1/2/(x + 1)
f = 1/(x^2+1) f.partial_fraction(x)
1/(x^2 + 1)
integral(sin), x)
1/8*((I - 1)*sqrt(2)*erf((1/2*I - 1/2)*sqrt(2)*x) + (I + 1)*sqrt(2)*erf((1/2*I + 1/2)*sqrt(2)*x))*sqrt(pi)
I??
could not find class definition
erf??

File: /usr/local/sage2/local/lib/python2.6/site-packages/sage/functions/other.py

Source Code (starting at line 26):

class Function_erf(BuiltinFunction):
    _eval_ = BuiltinFunction._eval_default
    def __init__(self):
        r"""
        The error function, defined as
        `\text{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt`.

        Sage currently only implements the error function (via a call to
        PARI) when the input is real.

        EXAMPLES::

            sage: erf(2)
            erf(2)
            sage: erf(2).n()
            0.995322265018953
            sage: loads(dumps(erf))
            erf

        The following fails because we haven't implemented
        erf yet for complex values::

            sage: complex(erf(3*I))
            Traceback (most recent call last):
            ...
            TypeError: unable to simplify to complex approximation

        TESTS:

        Check if conversion from maxima elements work::

            sage: merf = maxima(erf(x)).sage().operator()
            sage: merf == erf
            True
        """
        BuiltinFunction.__init__(self, "erf", latex_name=r"\text{erf}")

    def _evalf_(self, x, parent=None):
        """
        EXAMPLES::

            sage: erf(2).n()
            0.995322265018953
            sage: erf(2).n(150)
            Traceback (most recent call last):
            ...
            NotImplementedError: erf not implemented for precision higher than 53
        """
        try:
            prec = parent.prec()
        except AttributeError: # not a Sage parent
            prec = 0
        if prec > 53:
            raise NotImplementedError, "erf not implemented for precision higher than 53"
        return parent(1 - pari(float(x)).erfc())

    def _derivative_(self, x, diff_param=None):
        """
        Derivative of erf function

        EXAMPLES::

            sage: erf(x).diff(x)
            2*e^(-x^2)/sqrt(pi)

        TESTS::

        Check if #8568 is fixed::

            sage: var('c,x')
            (c, x)
            sage: derivative(erf(c*x),x)
            2*c*e^(-c^2*x^2)/sqrt(pi)
            sage: erf(c*x).diff(x)._maxima_init_()
            '((%pi)^(-1/2))*(c)*(exp(((c)^(2))*((x)^(2))*(-1)))*(2)'
        """
        return 2*exp(-x**2)/sqrt(pi)
x=var('x') integral(e^(-x^2),x)
1/2*sqrt(pi)*erf(x)
plot(erf(x),x)
plot(1-erf(x),x)
t = var('t') x=function('x',t) DE = diff(x,t) + x - 1 desolve(DE,[x,t])
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_71.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dCA9IHZhcigndCcpCiB4PWZ1bmN0aW9uKCd4Jyx0KQogREUgPSBkaWZmKHgsdCkgKyB4IC0gMQpkZXNvbHZlKERFLFt4LHRdKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmpDitRAc/___code___.py", line 4 x=function('x',t) ^ IndentationError: unexpected indent