<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> <TITLE> S-Lang Run-Time Library Reference: Version 1.4.0: Mathematical Functions</TITLE> <LINK HREF="slangfun-7.html" REL=next> <LINK HREF="slangfun-5.html" REL=previous> <LINK HREF="slangfun.html#toc6" REL=contents> </HEAD> <BODY> <A HREF="slangfun-7.html">Next</A> <A HREF="slangfun-5.html">Previous</A> <A HREF="slangfun.html#toc6">Contents</A> <HR> <H2><A NAME="s6">6. Mathematical Functions</A></H2> <P> <H2><A NAME="Conj"></A> <A NAME="ss6.1">6.1 <B>Conj</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the complex conjugate of a number <DT><B> Usage </B><DD><P><CODE>z1 = Conj (z)</CODE> <DT><B> Description </B><DD><P>The <CODE>Conj</CODE> function returns the complex conjugate of a number. If its argument is an array, the <CODE>Conj</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>Real, Imag, abs</CODE> </DL> <P> <P> <H2><A NAME="Imag"></A> <A NAME="ss6.2">6.2 <B>Imag</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the imaginary part of a number <DT><B> Usage </B><DD><P><CODE>i = Imag (z)</CODE> <DT><B> Description </B><DD><P>The <CODE>Imag</CODE> function returns the imaginary part of a number. If its argument is an array, the <CODE>Imag</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>Real, Conj, abs</CODE> </DL> <P> <P> <H2><A NAME="Real"></A> <A NAME="ss6.3">6.3 <B>Real</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the real part of a number <DT><B> Usage </B><DD><P><CODE>r = Real (z)</CODE> <DT><B> Description </B><DD><P>The <CODE>Real</CODE> function returns the real part of a number. If its argument is an array, the <CODE>Real</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>Imag, Conj, abs</CODE> </DL> <P> <P> <H2><A NAME="abs"></A> <A NAME="ss6.4">6.4 <B>abs</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the absolute value of a number <DT><B> Usage </B><DD><P><CODE>y = abs(x)</CODE> <DT><B> Description </B><DD><P>The <CODE>abs</CODE> function returns the absolute value of an arithmetic type. If its argument is a complex number (<CODE>Complex_Type</CODE>), then it returns the modulus. If the argument is an array, a new array will be created whose elements are obtained from the original array by using the <CODE>abs</CODE> function. <DT><B> See Also </B><DD><P><CODE>sign, sqr</CODE> </DL> <P> <P> <H2><A NAME="acos"></A> <A NAME="ss6.5">6.5 <B>acos</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the arc-cosine of an number <DT><B> Usage </B><DD><P><CODE>y = acos (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>acos</CODE> function computes the arc-cosine of a number and returns the result as an array. If its argument is an array, the <CODE>acos</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="acosh"></A> <A NAME="ss6.6">6.6 <B>acosh</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the inverse cosh of an number <DT><B> Usage </B><DD><P><CODE>y = acosh (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>acosh</CODE> function computes the inverse cosh of a number and returns the result as an array. If its argument is an array, the <CODE>acosh</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="asin"></A> <A NAME="ss6.7">6.7 <B>asin</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the arc-sine of an number <DT><B> Usage </B><DD><P><CODE>y = asin (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>asin</CODE> function computes the arc-sine of a number and returns the result as an array. If its argument is an array, the <CODE>asin</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="asinh"></A> <A NAME="ss6.8">6.8 <B>asinh</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the inverse-sinh of an number <DT><B> Usage </B><DD><P><CODE>y = asinh (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>asinh</CODE> function computes the inverse-sinh of a number and returns the result as an array. If its argument is an array, the <CODE>asinh</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="atan"></A> <A NAME="ss6.9">6.9 <B>atan</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the arc-tangent of an number <DT><B> Usage </B><DD><P><CODE>y = atan (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>atan</CODE> function computes the arc-tangent of a number and returns the result as an array. If its argument is an array, the <CODE>atan</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="atanh"></A> <A NAME="ss6.10">6.10 <B>atanh</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the inverse-tanh of an number <DT><B> Usage </B><DD><P><CODE>y = atanh (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>atanh</CODE> function computes the inverse-tanh of a number and returns the result as an array. If its argument is an array, the <CODE>atanh</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="cos"></A> <A NAME="ss6.11">6.11 <B>cos</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the cosine of an number <DT><B> Usage </B><DD><P><CODE>y = cos (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>cos</CODE> function computes the cosine of a number and returns the result as an array. If its argument is an array, the <CODE>cos</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="cosh"></A> <A NAME="ss6.12">6.12 <B>cosh</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the hyperbolic cosine of an number <DT><B> Usage </B><DD><P><CODE>y = cosh (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>cosh</CODE> function computes the hyperbolic cosine of a number and returns the result as an array. If its argument is an array, the <CODE>cosh</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="exp"></A> <A NAME="ss6.13">6.13 <B>exp</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the exponential of an number <DT><B> Usage </B><DD><P><CODE>y = exp (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>exp</CODE> function computes the exponential of a number and returns the result as an array. If its argument is an array, the <CODE>exp</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="log"></A> <A NAME="ss6.14">6.14 <B>log</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the logarithm of an number <DT><B> Usage </B><DD><P><CODE>y = log (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>log</CODE> function computes the logarithm of a number and returns the result as an array. If its argument is an array, the <CODE>log</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="log10"></A> <A NAME="ss6.15">6.15 <B>log10</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the base-10 logarithm of an number <DT><B> Usage </B><DD><P><CODE>y = log10 (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>log10</CODE> function computes the base-10 logarithm of a number and returns the result as an array. If its argument is an array, the <CODE>log10</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="mul2"></A> <A NAME="ss6.16">6.16 <B>mul2</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Multiply a number by 2 <DT><B> Usage </B><DD><P><CODE>y = mul2(x)</CODE> <DT><B> Description </B><DD><P>The <CODE>mul2</CODE> function multiplies an arithmetic type by two and returns the result. If its argument is an array, a new array will be created whose elements are obtained from the original array by using the <CODE>mul2</CODE> function. <DT><B> See Also </B><DD><P><CODE>sqr, abs</CODE> </DL> <P> <P> <H2><A NAME="polynom"></A> <A NAME="ss6.17">6.17 <B>polynom</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Evaluate a polynomial <DT><B> Usage </B><DD><P><CODE>Double_Type polynom(Double_Type a, b, ...c, Integer_Type n, Double_Type x)</CODE> <DT><B> Description </B><DD><P>The <CODE>polynom</CODE> function returns the value of the polynomial expression: <BLOCKQUOTE><CODE> <PRE> ax^n + bx^(n - 1) + ... c </PRE> </CODE></BLOCKQUOTE> <DT><B> Notes </B><DD><P>The <CODE>polynom</CODE> function should be extended to work with complex and array data types. The current implementation is limited to <CODE>Double_Type</CODE> quantities. <DT><B> See Also </B><DD><P><CODE>exp</CODE> </DL> <P> <P> <H2><A NAME="set_float_format"></A> <A NAME="ss6.18">6.18 <B>set_float_format</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Set the format for printing floating point values. <DT><B> Usage </B><DD><P><CODE>set_float_format (String_Type fmt)</CODE> <DT><B> Description </B><DD><P>The <CODE>set_float_format</CODE> function is used to set the floating point format to be used when floating point numbers are printed. The routines that use this are the traceback routines and the <CODE>string</CODE> function. The default value is <CODE>"%f"</CODE> <DT><B> Example </B><DD><P> <BLOCKQUOTE><CODE> <PRE> s = string (PI); % --> s = "3.14159" set_float_format ("%16.10f"); s = string (PI); % --> s = "3.1415926536" set_float_format ("%10.6e"); s = string (PI); % --> s = "3.141593e+00" </PRE> </CODE></BLOCKQUOTE> <DT><B> See Also </B><DD><P><CODE>string, sprintf, double</CODE> </DL> <P> <P> <H2><A NAME="sign"></A> <A NAME="ss6.19">6.19 <B>sign</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the sign of a number <DT><B> Usage </B><DD><P><CODE>y = sign(x)</CODE> <DT><B> Description </B><DD><P>The <CODE>sign</CODE> function returns the sign of an arithmetic type. If its argument is a complex number (<CODE>Complex_Type</CODE>), it returns the sign of the imaginary part of the number. If the argument is an array, a new array will be created whose elements are obtained from the original array by using the <CODE>sign</CODE> function. <P>When applied to a real number or an integer, the <CODE>sign</CODE> function returns <CODE>-1</CODE>, <CODE>0</CODE>, or <CODE>+1</CODE> according to whether the number is less than zero, equal to zero, or greater than zero, respectively. <DT><B> See Also </B><DD><P><CODE>abs</CODE> </DL> <P> <P> <H2><A NAME="sin"></A> <A NAME="ss6.20">6.20 <B>sin</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the sine of an number <DT><B> Usage </B><DD><P><CODE>y = sin (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>sin</CODE> function computes the sine of a number and returns the result as an array. If its argument is an array, the <CODE>sin</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="sinh"></A> <A NAME="ss6.21">6.21 <B>sinh</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the hyperbolic sine of an number <DT><B> Usage </B><DD><P><CODE>y = sinh (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>sinh</CODE> function computes the hyperbolic sine of a number and returns the result as an array. If its argument is an array, the <CODE>sinh</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="sqr"></A> <A NAME="ss6.22">6.22 <B>sqr</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the square of a number <DT><B> Usage </B><DD><P><CODE>y = sqr(x)</CODE> <DT><B> Description </B><DD><P>The <CODE>sqr</CODE> function returns the square of an arithmetic type. If its argument is a complex number (<CODE>Complex_Type</CODE>), then it returns the square of the modulus. If the argument is an array, a new array will be created whose elements are obtained from the original array by using the <CODE>sqr</CODE> function. <DT><B> See Also </B><DD><P><CODE>abs, mul2</CODE> </DL> <P> <P> <H2><A NAME="sqrt"></A> <A NAME="ss6.23">6.23 <B>sqrt</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the square root of an number <DT><B> Usage </B><DD><P><CODE>y = sqrt (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>sqrt</CODE> function computes the square root of a number and returns the result as an array. If its argument is an array, the <CODE>sqrt</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>sqr, cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="tan"></A> <A NAME="ss6.24">6.24 <B>tan</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the tangent of an number <DT><B> Usage </B><DD><P><CODE>y = tan (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>tan</CODE> function computes the tangent of a number and returns the result as an array. If its argument is an array, the <CODE>tan</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <H2><A NAME="tanh"></A> <A NAME="ss6.25">6.25 <B>tanh</B></A> </H2> <P> <DL> <DT><B> Synopsis </B><DD><P>Compute the hyperbolic tangent of an number <DT><B> Usage </B><DD><P><CODE>y = tanh (x)</CODE> <DT><B> Description </B><DD><P>The <CODE>tanh</CODE> function computes the hyperbolic tangent of a number and returns the result as an array. If its argument is an array, the <CODE>tanh</CODE> function will be applied to each element and the result returned as an array. <DT><B> See Also </B><DD><P><CODE>cos, atan, acosh, cosh</CODE> </DL> <P> <P> <P> <HR> <A HREF="slangfun-7.html">Next</A> <A HREF="slangfun-5.html">Previous</A> <A HREF="slangfun.html#toc6">Contents</A> </BODY> </HTML>