(directly go to documentation on : Sin, Cos, Tan, ArcSin, ArcCos, ArcTan, Exp, Ln, Sqrt, Abs, Sign, D, Curl, Diverge, Integrate, Limit. )

4. Calculus and elementary functions

In this chapter, some facilities for doing calculus are described. These include functions implementing differentiation, integration, standard mathematical functions, and solving of equations.

Sin trigonometric sine function
Cos trigonometric cosine function
Tan trigonometric tangent function
ArcSin inverse trigonometric function arc-sine
ArcCos inverse trigonometric function arc-cosine
ArcTan inverse trigonometric function arc-tangent
Exp exponential function
Ln natural logarithm
Sqrt square root
Abs absolute value or modulus of complex number
Sign sign of a number
D take derivative of expression with respect to variable
Curl curl of a vector field
Diverge divergence of a vector field
Integrate integration
Limit limit of an expression


Sin -- trigonometric sine function

Standard library
Calling format:
Sin(x)

Parameters:
x -- argument to the function, in radians

Description:
This function represents the trigonometric function sine. Yacas leaves expressions alone even if x is a number, trying to keep the result as exact as possible. The floating point approximations of these functions can be forced by using the N function.

Yacas knows some trigonometric identities, so it can simplify to exact results even if N is not used. This is the case, for instance, when the argument is a multiple of Pi/6 or Pi/4.

These functions are threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Sin(1)
Out> Sin(1);
In> N(Sin(1),20)
Out> 0.84147098480789650665;
In> Sin(Pi/4)
Out> Sqrt(2)/2;

See also:
Cos , Tan , ArcSin , ArcCos , ArcTan , N , Pi .


Cos -- trigonometric cosine function

Standard library
Calling format:
Cos(x)

Parameters:
x -- argument to the function, in radians

Description:
This function represents the trigonometric function cosine. Yacas leaves expressions alone even if x is a number, trying to keep the result as exact as possible. The floating point approximations of these functions can be forced by using the N function.

Yacas knows some trigonometric identities, so it can simplify to exact results even if N is not used. This is the case, for instance, when the argument is a multiple of Pi/6 or Pi/4.

These functions are threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Cos(1)
Out> Cos(1);
In> N(Cos(1),20)
Out> 0.5403023058681397174;
In> Cos(Pi/4)
Out> Sqrt(1/2);

See also:
Sin , Tan , ArcSin , ArcCos , ArcTan , N , Pi .


Tan -- trigonometric tangent function

Standard library
Calling format:
Tan(x)

Parameters:
x -- argument to the function, in radians

Description:
This function represents the trigonometric function tangent. Yacas leaves expressions alone even if x is a number, trying to keep the result as exact as possible. The floating point approximations of these functions can be forced by using the N function.

Yacas knows some trigonometric identities, so it can simplify to exact results even if N is not used. This is the case, for instance, when the argument is a multiple of Pi/6 or Pi/4.

These functions are threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Tan(1)
Out> Tan(1);
In> N(Tan(1),20)
Out> 1.5574077246549022305;
In> Tan(Pi/4)
Out> 1;

See also:
Sin , Cos , ArcSin , ArcCos , ArcTan , N , Pi .


ArcSin -- inverse trigonometric function arc-sine

Standard library
Calling format:
ArcSin(x)

Parameters:
x -- argument to the function

Description:
This function represents the inverse trigonometric function arcsine. For instance, the value of ArcSin(x) is a number y such that Sin(y) equals x.

Note that the number y is not unique. For instance, Sin(0) and Sin(Pi) both equal 0, so what should ArcSin(0) be? In Yacas, it is agreed that the value of ArcSin(x) should be in the interval [-Pi/2, Pi/2].

Usually, Yacas leaves this function alone unless it is forced to do a numerical evaluation by the N function. If the argument is -1, 0, or 1 however, Yacas will simplify the expression. If the argument is complex, the expression will be rewritten using the Ln function.

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> ArcSin(1)
Out> Pi/2;

In> ArcSin(1/3)
Out> ArcSin(1/3);
In> Sin(ArcSin(1/3))
Out> 1/3;

In> x:=N(ArcSin(0.75))
Out> 0.848062;
In> N(Sin(x))
Out> 0.7499999477;

See also:
Sin , Cos , Tan , N , Pi , Ln , ArcCos , ArcTan .


ArcCos -- inverse trigonometric function arc-cosine

Standard library
Calling format:
ArcCos(x)

Parameters:
x -- argument to the function

Description:
This function represents the inverse trigonometric function arc-cosine. For instance, the value of ArcCos(x) is a number y such that Cos(y) equals x.

Note that the number y is not unique. For instance, Cos(Pi/2) and Cos(3*Pi/2) both equal 0, so what should ArcCos(0) be? In Yacas, it is agreed that the value of ArcCos(x) should be in the interval [0,Pi] .

Usually, Yacas leaves this function alone unless it is forced to do a numerical evaluation by the N function. If the argument is -1, 0, or 1 however, Yacas will simplify the expression. If the argument is complex, the expression will be rewritten using the Ln function.

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> ArcCos(0)
Out> Pi/2

In> ArcCos(1/3)
Out> ArcCos(1/3)
In> Cos(ArcCos(1/3))
Out> 1/3

In> x:=N(ArcCos(0.75))
Out> 0.7227342478
In> N(Cos(x))
Out> 0.75

See also:
Sin , Cos , Tan , N , Pi , Ln , ArcSin , ArcTan .


ArcTan -- inverse trigonometric function arc-tangent

Standard library
Calling format:
ArcTan(x)

Parameters:
x -- argument to the function

Description:
This function represents the inverse trigonometric function arctangent. For instance, the value of ArcTan(x) is a number y such that Tan(y) equals x.

Note that the number y is not unique. For instance, Tan(0) and Tan(2*Pi) both equal 0, so what should ArcTan(0) be? In Yacas, it is agreed that the value of ArcTan(x) should be in the interval [-Pi/2, Pi/2].

Usually, Yacas leaves this function alone unless it is forced to do a numerical evaluation by the N function. Yacas will try to simplify as much as possible while keeping the result exact. If the argument is complex, the expression will be rewritten using the Ln function.

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> ArcTan(1)
Out> Pi/4

In> ArcTan(1/3)
Out> ArcTan(1/3)
In> Tan(ArcTan(1/3))
Out> 1/3

In> x:=N(ArcTan(0.75))
Out> 0.643501108793285592213351264945231378078460693359375
In> N(Tan(x))
Out> 0.75

See also:
Sin , Cos , Tan , N , Pi , Ln , ArcSin , ArcCos .


Exp -- exponential function

Standard library
Calling format:
Exp(x)

Parameters:
x -- argument to the function

Description:
This function calculates e raised to the power x, where e is the mathematic constant 2.71828... One can use Exp(1) to represent e.

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Exp(0)
Out> 1;
In> Exp(I*Pi)
Out> -1;
In> N(Exp(1))
Out> 2.7182818284;

See also:
Ln , Sin , Cos , Tan , N .


Ln -- natural logarithm

Standard library
Calling format:
Ln(x)

Parameters:
x -- argument to the function

Description:
This function calculates the natural logarithm of "x". This is the inverse function of the exponential function, Exp, i.e. Ln(x)=y implies that Exp(y)=x. For complex arguments, the imaginary part of the logarithm is in the interval (- Pi, Pi]. This is compatible with the branch cut of Arg.

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Ln(1)
Out> 0;
In> Ln(Exp(x))
Out> x;
In> D(x) Ln(x)
Out> 1/x;

See also:
Exp , Arg .


Sqrt -- square root

Standard library
Calling format:
Sqrt(x)

Parameters:
x -- argument to the function

Description:
This function calculates the square root of "x". If the result is not rational, the call is returned unevaluated unless a numerical approximation is forced with the N function. This function can also handle negative and complex arguments.

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Sqrt(16)
Out> 4;
In> Sqrt(15)
Out> Sqrt(15);
In> N(Sqrt(15))
Out> 3.8729833462;
In> Sqrt(4/9)
Out> 2/3;
In> Sqrt(-1)
Out> Complex(0,1);

See also:
Exp , ^ , N .


Abs -- absolute value or modulus of complex number

Standard library
Calling format:
Abs(x)

Parameters:
x -- argument to the function

Description:
This function returns the absolute value (also called the modulus) of "x". If "x" is positive, the absolute value is "x" itself; if "x" is negative, the absolute value is "-x". For complex "x", the modulus is the "r" in the polar decomposition x=r*Exp(I*phi).

This function is connected to the Sign function by the identity "Abs(x) * Sign(x) = x" for real "x".

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Abs(2);
Out> 2;
In> Abs(-1/2);
Out> 1/2;
In> Abs(3+4*I);
Out> 5;

See also:
Sign , Arg .


Sign -- sign of a number

Standard library
Calling format:
Sign(x)

Parameters:
x -- argument to the function

Description:
This function returns the sign of the real number x. It is "1" for positive numbers and "-1" for negative numbers. Somewhat arbitrarily, Sign(0) is defined to be 1.

This function is connected to the Abs function by the identity Abs(x)*Sign(x)=x for real x.

This function is threaded, meaning that if the argument x is a list, the function is applied to all entries in the list.

Examples:
In> Sign(2)
Out> 1;
In> Sign(-3)
Out> -1;
In> Sign(0)
Out> 1;
In> Sign(-3) * Abs(-3)
Out> -3;

See also:
Arg , Abs .


D -- take derivative of expression with respect to variable

Standard library
Calling format:
D(variable) expression
D(list) expression
D(variable,n) expression

Parameters:
variable -- variable

list -- a list of variables

expression -- expression to take derivatives of

n -- order of derivative

Description:
This function calculates the derivative of the expression expr with respect to the variable var and returns it. If the third calling format is used, the n-th derivative is determined. Yacas knows how the differentiate standard functions such as Ln and Sin.

The D operator is threaded in both var and expr. This means that if either of them is a list, the function is applied to each entry in the list. The results are collected in another list which is returned. If both var and expr are a list, their lengths should be equal. In this case, the first entry in the list expr is differentiated with respect to the first entry in the list var, the second entry in expr is differentiated with respect to the second entry in var, and so on.

The D operator returns the original function if n=0, a common mathematical idiom that simplifies many formulae.

Examples:
In> D(x)Sin(x*y)
Out> y*Cos(x*y);
In> D({x,y,z})Sin(x*y)
Out> {y*Cos(x*y),x*Cos(x*y),0};
In> D(x,2)Sin(x*y)
Out> -Sin(x*y)*y^2;
In> D(x){Sin(x),Cos(x)}
Out> {Cos(x),-Sin(x)};

See also:
Integrate , Taylor , Diverge , Curl .


Curl -- curl of a vector field

Standard library
Calling format:
Curl(vector, basis)

Parameters:
vector -- vector field to take the curl of

basis -- list of variables forming the basis

Description:
This function takes the curl of the vector field "vector" with respect to the variables "basis". The curl is defined in the usual way,

Curl(f,x) = {
    D(x[2]) f[3] - D(x[3]) f[2],
    D(x[3]) f[1] - D(x[1]) f[3],
    D(x[1]) f[2] - D(x[2]) f[1]
}
Both "vector" and "basis" should be lists of length 3.

Example:
In> Curl({x*y,x*y,x*y},{x,y,z})
Out> {x,-y,y-x};

See also:
D , Diverge .


Diverge -- divergence of a vector field

Standard library
Calling format:
Diverge(vector, basis)

Parameters:
vector -- vector field to calculate the divergence of

basis -- list of variables forming the basis

Description:
This function calculates the divergence of the vector field "vector" with respect to the variables "basis". The divergence is defined as

Diverge(f,x) = D(x[1]) f[1] + ...
    + D(x[n]) f[n],
where n is the length of the lists "vector" and "basis". These lists should have equal length.

Example:
In> Diverge({x*y,x*y,x*y},{x,y,z})
Out> y+x;

See also:
D , Curl .


Integrate -- integration

Standard library
Calling format:
Integrate(var, x1, x2) expr
Integrate(var) expr

Parameters:
var -- atom, variable to integrate over

x1 -- first point of definite integration

x2 -- second point of definite integration

expr -- expression to integrate

Description:
This function integrates the expression expr with respect to the variable var. The first calling format is used to perform definite integration: the integration is carried out from var=x1 to var=x2". The second form is for indefinite integration.

Some simple integration rules have currently been implemented. Polynomials, some quotients of polynomials, trigonometric functions and their inverses, hyperbolic functions and their inverses, Exp, and Ln, and products of these functions with polynomials can be integrated.

Examples:
In> Integrate(x,a,b) Cos(x)
Out> Sin(b)-Sin(a);
In> Integrate(x) Cos(x)
Out> Sin(x);

See also:
D , UniqueConstant .


Limit -- limit of an expression

Standard library
Calling format:
Limit(var, val) expr
Limit(var, val, dir) expr

Parameters:
var -- a variable

val -- a number

dir -- a direction (Left or Right)

expr -- an expression

Description:
This command tries to determine the value that the expression "expr" converges to when the variable "var" approaches "val". One may use Infinity or -Infinity for "val". The result of Limit may be one of the symbols Undefined (meaning that the limit does not exist), Infinity, or -Infinity.

The second calling sequence is used for unidirectional limits. If one gives "dir" the value Left, the limit is taken as "var" approaches "val" from the positive infinity; and Right will take the limit from the negative infinity.

Examples:
In> Limit(x,0) Sin(x)/x
Out> 1;
In> Limit(x,0) (Sin(x)-Tan(x))/(x^3)
Out> -1/2;
In> Limit(x,0) 1/x
Out> Undefined;
In> Limit(x,0,Left) 1/x
Out> -Infinity;
In> Limit(x,0,Right) 1/x
Out> Infinity;