Basic Mathematical Functions in Scilab

Even if it’s capable of very complex numerical computations, Scilab can be used only as a simple or scientific calculator. The most common functions are those related to trigonometry, logarithms and basic statistics. In the table below the basic mathematical functions defined in Scilab are explained.

How to install Scilab

General functions

Mathematical function Scilab function Mathematical formula
square root sqrt(x) \[ \begin{equation*} \begin{split}
\sqrt{x}
\end{split} \end{equation*} \]
exponential exp(x) \[ \begin{equation*} \begin{split}
e^x
\end{split} \end{equation*} \]
natural algorithm log(x) \[ \begin{equation*} \begin{split}
ln(x)
\end{split} \end{equation*} \]
decimal logarithm log10(x) \[ \begin{equation*} \begin{split}
log(x)
\end{split} \end{equation*} \]
absolute value abs(x) \[ \begin{equation*} \begin{split}
\left | x \right |
\end{split} \end{equation*} \]

Trigonometry functions

Mathematical function Scilab function Mathematical formula
sine sin(x) \[ \begin{equation*} \begin{split}
sin(x), x \hspace{2mm} in \hspace{2mm} radians
\end{split} \end{equation*} \]
cosine cos(x) \[ \begin{equation*} \begin{split}
cos(x), x \hspace{2mm} in \hspace{2mm} radians
\end{split} \end{equation*} \]
tangent tan(x) \[ \begin{equation*} \begin{split}
tg(x), x \hspace{2mm} in \hspace{2mm} radians
\end{split} \end{equation*} \]
cotangent cotg(x) \[ \begin{equation*} \begin{split}
ctg(x), x \hspace{2mm} in \hspace{2mm} radians
\end{split} \end{equation*} \]
arc-sine asin(x) \[ \begin{equation*} \begin{split}
y = arcsin(x), x = sin(y)
\end{split} \end{equation*} \]
arc-cosine acos(x) \[ \begin{equation*} \begin{split}
y = arccos(x), x = cos(y)
\end{split} \end{equation*} \]
arc-tangent atan(x) \[ \begin{equation*} \begin{split}
y = arctg(x), x = tg(y)
\end{split} \end{equation*} \]
arc-cotangent acot(x) \[ \begin{equation*} \begin{split}
y = arcctg(x), x = ctg(y)
\end{split} \end{equation*} \]
hyperbolic sine sinh(x) \[ \begin{equation*} \begin{split}
sinh(x) = \frac{e^x – e^{-x}}{2}
\end{split} \end{equation*} \]
hyperbolic cosine cosh(x) \[ \begin{equation*} \begin{split}
cosh(x) = \frac{e^{2 \cdot x} + 1}{2 \cdot e^x}
\end{split} \end{equation*} \]
hyperbolic tangent tanh(x) \[ \begin{equation*} \begin{split}
tanh(x) = \frac{e^{2 \cdot x} – 1}{e^{2 \cdot x} + 1}
\end{split} \end{equation*} \]
hyperbolic cotangent coth(x) \[ \begin{equation*} \begin{split}
coth(x) = \frac{e^{2 \cdot x} + 1}{e^{2 \cdot x} – 1}
\end{split} \end{equation*} \]
sinc sinc(x) \[ \begin{equation*} \begin{split}
sinc(x) = \frac{sin(x)}{x}
\end{split} \end{equation*} \]

It is important to keep in mind that the argument for the trigonometric functions should be in radians. To transform from degrees in radians we use the following formula:

\[ \begin{equation*} \begin{split}
\alpha [rad] = \alpha [^{\circ}] \cdot \frac{\pi}{180^{\circ}}
\end{split} \end{equation*} \]

Example, the sine function of an angle of 90°:

-->sin(90 * %pi/180)
 ans =
 
 1. 
 
-->

Statistical functions

Mathematical function Scilab function Description
minimum min(x) \[ \begin{equation*} \begin{split}
x = [x_1, x_2, …]
\end{split} \end{equation*} \]
maximum max(x) \[ \begin{equation*} \begin{split}
x = [x_1, x_2, …]
\end{split} \end{equation*} \]
round round(x) \[ \begin{equation*} \begin{split}
outputs \hspace{2mm} the \hspace{2mm} closest \hspace{2mm} integer \hspace{2mm} of \hspace{2mm} x
\end{split} \end{equation*} \]
ceil ceil(x) \[ \begin{equation*} \begin{split}
outputs \hspace{2mm} the \hspace{2mm} integer \hspace{2mm} part \hspace{2mm} of \hspace{2mm} x + 1
\end{split} \end{equation*} \]
floor floor(x) \[ \begin{equation*} \begin{split}
outputs \hspace{2mm} the \hspace{2mm} integer \hspace{2mm} part \hspace{2mm} of \hspace{2mm} x
\end{split} \end{equation*} \]

Example:

-->min([1 2 3]) + max([-2 0 1]) + round(0.6) + ceil(0.1) + floor(1.9)
 ans =
 
 5. 
 
-->

In order to get used to Scilab basic functions try the examples below:

\[ \begin{equation*} \begin{split}
e^2 + \left ( \frac{\pi}{3}\right)^3 + ln(7) – log_{10} 5 + \sqrt{18^4}
\end{split} \end{equation*} \]
-->exp(2)+(%pi/2)^3+log(7)-log10(5)+sqrt(18^4)

ans =

336.51178

-->
\[ \begin{equation*} \begin{split}
sinc(x) + tan(x)^3 – 5 \cdot \frac{ctg(x)}{arccos(x)} – cosh(x), \hspace{2mm} x = \frac{\pi}{5}
\end{split} \end{equation*} \]
-->x=%pi/5

x = 
 0.6283185 
 
-->sinc(x)+tan(x)^3-5*(cotg(x)/acos(x))-cosh(x)

ans = 
 - 7.60525 
 
-->

The best way to get use with the Scilab basic functions syntax, is to try a couple of mathematical expressions which should include basic, trigonometry and statistical functions. After some practice names and arguments of the functions will be easy to remember and use.

For any questions, observations and queries regarding Scilab variables use the comment form below.

Don’t forget to Like, Share and Subscribe!

One Response

  1. Tara shankar Mohapatra

Leave a Reply

Ad Blocker Detected

Dear user, Our website provides free and high quality content by displaying ads to our visitors. Please support us by disabling your Ad blocker for our site. Thank you!

Refresh