Examples by topic ================= Differentiation --------------- The operator ``df`` is used to represent partial differentiation with respect to one or more variables. .. pull-quote:: ``syntax: df exprn [var ]+.`` Differentiation of the function :math:`x^2 y^3 z^4` with respect to :math:`x,y,z`, two, three and four times respectively, i.e :math:`\frac{\partial^9 x^2 y^3 z^4}{\partial x^2 \partial y^3 \partial z^4}`: .. code:: python > simplify $ df (x^2*y^3*z^4) x 2 y 3 z 4 ; 288 The derivative of :math:`\log \sin (x)^2`: .. code:: python > simplify $ df (log(sin x)^2) x; 2*cos x*log (sin x)/sin x Note the parentheses. Suppose :math:`z(\cos(x),y)`: Let's calculate :math:`\frac{\partial \sin(z)} {\partial \cos(x)}` and :math:`\frac{\partial z^2}{\partial x}` : .. code:: python > declare depend [z,cos x,y]; [] > simplify (df (sin z) (cos x)); cos z*df z (cos x) > simplify (df (z^2) x); 2*df z x*z Note how to declare dependencies. The results are :math:`\cos(z) \frac{\partial z} {\partial \cos(x)}` and :math:`2 z \frac{\partial z} {\partial x})` respectively, as expected. Integration ----------- ``INT`` is an operator in ``REDUCE`` for indefinite integration using a combination of the Risch-Norman algorithm and pattern matching. .. pull-quote:: ``syntax: intg exprn var.`` Note that in ``Pure`` the operator is called ``intg`` in order not to clash with the integer type ``int``. Example 1: .. math:: \int \frac{1}{a x + b} dx .. code:: python > simplify $ intg (1/(a*x+b)) x; log (a*x+b)/a Example 2: .. math:: I(a,b,n) = \int x^2 (a x + b)^n dx .. code:: python > I a b n = simplify $ intg (x^2*(a*x+b)^n) x; > I a b n; ((a*x+b)^n*a^3*n^2*x^3+3*(a*x+b)^n*a^3*n*x^3+2*(a*x+b)^n*a^3*x^3+ (a*x+b)^n*a^2*b*n^2*x^2+(a*x+b)^n*a^2*b*n*x^2-2*(a*x+b)^n*a*b^2* n*x+2*(a*x+b)^n*b^3)/(a^3*n^3+6*a^3*n^2+11*a^3*n+6*a^3) > I a b 0 ; x^3/3 > I 0 b n; b^n*x^3/3 > I a 0 k; x^k*a^k*x^3/(k+3) Example 3: .. math:: \int \frac{\sqrt{x+\sqrt{x^2+1}}}{x} .. code:: python > simplify $ intg (sqrt(x+sqrt(x^2+1))/x) x ; intg (sqrt (sqrt (x^2+1)+x)/x) x Apparently no solution was found. There is a package ``ALGINT`` in REDUCE, that is specialized to deal with algebraic functions. The [UserGuide]_ says .. pull-quote:: ... *will analytically integrate a wide range of expressions involving square roots where the answer exists in that class of functions. It is an implementation of the work described in J.H. Davenport* [LNCS102]_ .. code:: python > reduce::load "algint" ; 0 > simplify $ intg (sqrt(x+sqrt(x^2+1))/x) x ; atan ((sqrt (sqrt (x^2+1)+x)*sqrt (x^2+1)-sqrt (sqrt (x^2+1)+x)*x-sqrt (sqrt (x^2+1)+x))/2)+2*sqrt (sqrt (x^2+1)+x)+log (sqrt (sqrt (x^2+1)+x)-1)-log (sqrt (sqrt (x^2+1)+x)+1) Note how to load packages. .. [UserGuide] REDUCE User Guide ref. .. [LNCS102] On the Integration of Algebraic Functions, LNCS 102, Springer Verlag, 1981.