diff(function,x) differentiates function with respect to the symbolic variable x. The main variable of function is used if x is not provided. Functions defined by user programs can often be handled as well.
>> syms a,x >> diff(a*x^3) ans = 3*a*x^2 >> diff(a*x^3,a) ans = x^3 >> diff(3*sqrt(exp(x)+2),x) ans = 1.5*exp(x)/sqrt(exp(x)+2) >> diff(sin(x)) % no variable specified ans = 1 % use z=sin(x) as variable >> diff(sin(x),x) % more reasonable ans = cos(x) >> function y=ttwo(x) y=2*x; end >> diff(ttwo(sin(x)),x) ans = 2*cos(x)
taylor(function, x, x0, n) calculates the n-th Taylorpolynomial in the symbolic variable x at the point x0.
integrate(function, x) integrates expression function with respect to the symbolic variable x. Jasymca uses the following strategy: Integrals of builtin-functions and all polynomials are provided:
>> syms x >> integrate(x^2+x-3,x) ans = 0.33333*x^3+0.5*x^2-3*x >> integrate(sin(x),x) ans = -cos(x)
If function is rational (i.e. quotient of two polynomials, whose coefficients do not depend on x)) we use the standard approach: Separate a polynomial part, then separate a square free part using Horowitz'  method, and finally integrate the rest using partial fractions. The final terms are collected to avoid complex expressions.
>> syms x >> y=(x^3+2*x^2-x+1)/((x+i)*(x-i)*(x+3)) y = (x^3+2*x^2-x+1)/(x^3+3*x^2+x+3) >> integrate(y,x) ans = -1/4*log(x^2+1)+(-1/2*log(x+3)+(-1/2*atan(x)+x)) >> diff(ans,x) % control ans = (x^3+2*x^2-x+1)/(x^3+3*x^2+x+3)
Expressions of type and are detected:
>> syms x >> integrate(x*exp(-2*x^2),x) ans = -0.25*exp(-2*x^2) >> integrate(exp(x)/(3+exp(x)),x) ans = log(exp(x)+3)
Substitutions of type are applied:
Products are fed through partial integration. This solves all cases where is one of exp, sin , cos , log , atan.
>> syms x >> integrate(x^3*exp(-2*x),x) ans = (-0.5*x^3-0.75*x^2-0.75*x-0.375)*exp(-2*x) >> integrate(x^2*log(x),x) ans = 0.33333*x^3*log(x)-0.11111*x^3
All trig and exp-functions are normalized. This solves any expression, which is the product of any number and any type of exponentials and trigonometric functions, and some cases of rational expressions of trig- and exp-functions
>> syms x >> integrate(sin(x)*cos(3*x)^2,x) ans = -3.5714E-2*cos(7*x)+(5.0E-2*cos(5*x)-0.5*cos(x)) >> integrate(1/(sin(3*x)+1),x) ans = -2/3*cos(3/2*x)/(sin(3/2*x)+cos(3/2*x))
The special case is implemented:
Clever substitutions may be supplied manually through subst(). If all fails, integrate numerically using quad or romberg. The symbolic variable may be omitted if it is the main variable of expression. Integrations can be quickly verified using diff() on the result.
Two routines are supplied for numerical integration, which are both not very sophisticated. quad('expression',ll,ul) is modelled after the Octave/Matlab integration function, but much simpler. Simpson's method is applied with a fixed number of nodes. This function uses the “eval”-method rather than symbolic variables. The function has to be supplied as quoted string, and must be compatible with vector arguments. Finally, the variable name must be x. romberg uses symbolic function definitions, and a symbolic variable has to be supplied. The maximum number of iterations is set by the variable rombergit (default ) and accuracy by rombergtol (default: ).
ode(expression,y,x) solves the linear first-order differential equation . expression is the complete right-hand-side of the equation, x and y are symbolic variables. Free constants in the solution are marked C.