Mathematics Science and Engineering Ubuntu

Install Scilab on Ubuntu

Scilab is a company that sells simulation and modeling services to industries. They have released their software under an open source license. The software looks like Octave and the programming language follows the same standards. It is also a mathematics programming language. It has many supporters and commercial support. The company that maintains it makes money from selling services to companies with a high demand on calculations.

Their are many companies that use this package and at the same time, most of them contribute code. You can find this in the built-in file manager. In this tool, you can also install the specific stuff that you need.  When starting out, creating and testing equations is practical. The language is easy to get started with. The capabilities when things get complex is impressive.

How to Install Scilab on Ubuntu

  1. Make sure your system is up to date.
    $ sudo apt update
    $ sudo apt upgrade
  2. Use apt to install.
    $ sudo apt install scilab

Scilab is also available as a tarball package from their website. The procedure is really simple:

Download the tarball and unpack it.

$ tar -xvf ~/Downloads/scilab-6.0.1.bin.linux-x86_64.tar.gz

The unpacking creates a directory structure in the current directory. To run scilab, cd to scilab-x.x.x/bin and run, you need no further installation. To update, just unpack the new tarball.

$ ./scilab

There are several executables, including scilab-cli, scilab-adv-cli and XML2Modelica. To begin with, start scilab plain. You will use the others when you get more advanced.

This is only the first step to get productive with Scilab. Packages are available both from your favorite repository and after you start the software yourself. If you use Ubuntu and go with the package approach, use the search function.

Find a matching package for your needs.

Here is an example, the celestlab library. This library, created by, you guessed it, Celestlab.

They use it to calculate trajectories for space flights and orbit analysis. They have released the package to the community. So go ahead, start planning your next space mission. 🙂

$ sudo apt search scilab-celestlab

When you start scilab next time, celestlab will be available in the Toolboxes menu. The documentation also shows up in the help browser, the best way to get to know the package is to use the code in the documentation. You can both run and copy the code into an empty file and change for your own functions.

The other way to install new packages is to search with the built-in function of the application. To do this, open the module manager from the Application menu. In there is a large collection of modules.  Some add mathematical capabilities for specific applications while others add communication capabilities. This includes a USB library and Arduino support.

If this is the first time you use scilab, start the demostrations from ‘?→ Scilab Demonstrations’ menu. What pops up is a long list of demonstration scripts to show you what you can use the software for. For example,  you can see samples of the different color themes available for graphs. The module ‘graphplot’ shows this in illustration 1:

Install Scilab Ubuntu

This part of Scilab can consume hours for the math geek but make sure you start coding with the help of these demos. You will see the executing code in the console and the result in a separate graph window. To see what is available, the best is to try out some calculations with the console. On the console, type in your expression and the result will appear below.

-->A=[1,2;2,4];

-->sinm(A)+0.5*%i*(expm(%i*A)-expm(-%i*A))
ans  =

0    0
0    0

In the above expression, the routine sets A as a matrix and the values are used in the calculation. Look carefully at the first statement, it ends with a semicolon. Without the semicolon the value would just show up in an answer on the line below and all information is lost.

This method mirrors how Octave works. You can use it to prototype small functions for bigger pieces of software, it can also be used to find solutions quickly to questions that pop up during work. Another important thing to note is that the procedure uses sinm, with an ‘m’ at the end. The ‘m’ denotes matrix the regular sin handles single numbers also, this is the same for most  available functions.

For people with some experience scripting, the octave language will look familiar in many ways. This is a deliberate choice from the designers.

Use a template file to see format. The top has comments, denoted by stars at the beginning of the row. A function looks like:

function area = squareof(a, b)
area = a * b
endfunction

To call this function you input a and b and expect area as the result.
In the console type

-->exec('/home/[username]/squareof.sci', -1)

-->squareof(4,4)
ans  =

-->

Scilab already includes many mathematical constants like pi, squareroot and trigonometric functions. When you have identified the area of interest you can find most functions for your particular area of interest.

You can also have variables inside the script that are local to the routine. When you get advanced, read the documentation for the modules you need and use their built-in functions.  The modules will help you learn the more intricate details of your narrow area. Your project needs a laser sharp focus for you to achieve something really useful.  Choose a module from Octave Forge to match your needs but don’t forget about all the stuff that are already built-in.

Conclusion

Scilab is a very powerful package and big institutions and businesses have adopted it. Given those facts, there is no surprise that the program crams in so many functions into the default package and still there are a wide array of extension packages for special industries and scientific jobs. A hobbyist can also plan electronic circuits and the path of a drone.  It is comforting to know that packages like this exist as open source so people can teach themselves things that ordinarily would be considered impossible for an “amateur”.

About the author

Mats Tage Axelsson

Mats Tage Axelsson

I am a freelance writer for Linux magazines. I enjoy finding out what is possible under Linux and how we can all chip in to improve it. I also cover renewable energy and the new way the grid operates. You can find more of my writing on my blog.