Jupyter scilab-kernel 0.10.0 has been released

image

Wish another interface for displaying Scilab results?

Jupyter is a project developing software for interactive computing across multiple programming languages. It proposed a new format named Notebook that is very appropriate for academia and demonstrations.

The project is open to most scientific languages including Scilab, this latter has its kernel named scilab-kernel developed by Dassault Systèmes and the community. This kernel implements features for Notebooks and other interfaces while leveraging latest Scilab behaviours.

t = linspace(0,6*%pi,100);
plot(sin(t))
plot(cos(t), 'r')
xgrid

image

For most users, Scilab software will be detected and started automatically on newly created notebooks. The notebook interface can display various information as the Scilab console does, but in a different way: each cell is like a mini-console. Values can be defined, printed and functions can be defined.

M = [0 0 1 ; 0 1 0 ; 1 0 0]
 M  = 
   0.   0.   1.
   0.   1.   0.
   1.   0.   0.
[2 3 4] * M
 ans  =
   4.   3.   2.
function r = myfunc()
  r = [4 5 6] * M
endfunction

All the features that display text to the console or figures are available on this interface. This makes it very easy to create a tutorials or courses on specific feature sets.

In the following example, we solve the differential equation dY/dt=A*Y where the unknown Y(t) is a 2-by-2 matrix. The exact solution is Y(t)=expm(A*t), where expm is the matrix exponential.

%latex $\textrm{solving a differential equation : } \dfrac{dy}{dt} = A * y$

function ydot = f(t, y, A)
    ydot = A*y;
endfunction

A = [1 1 ; 0 2];
y0 = eye(A);
t0 = 0;
t = 1;
ode_result = ode(y0, t0, t, list(f,A))

// Compare with the exact solution:
analytical_result = expm(A*t)
adams_result = ode("adams", y0, t0, t, f)

\textrm{solving a differential equation : } \dfrac{dy}{dt} = A * y

     ode_result  = 
       2.7182818   4.6707744
       0.          7.3890563
     analytical_result  = 
       2.7182818   4.6707743
       0.          7.3890561
     adams_result  = 
       2.7182818   4.6707747
       0.          7.3890565
    

For more experienced users, to go further behind simple code, the Scilab functions can be defined as macros and loaded hidden on specific macro files. All .sce files next to the notebook .ipynb file are loaded at kernel startup. This makes it easy to use one or more toolbox codes in the notebook; everything will be loaded at startup without modifying the current Scilab installation.

For example, the companion display_complex_plots.sci macro file is next to this file and defines a display_complex_plot() function.

display_complex_plots()

image

To go further, you can install the Scilab kernel from PyPi. By the way, this post has been written as a Notebook available here.

As usual, don’t hesitate to share with us your use cases and issues.

4 Likes

Thanks @davidcl
That’s a nice feature. I like Jupyter notebooks.
I test it briefly and it works perfectly on my Windows 10 install with Anaconda Python and Scilab-2023.1.0 (I know it’s a bit outdated)

Have you ever try some reactive notebooks ? (Marimo for Python ou Pluto.jl for Julia

Jupyter also have a reactive kernel for Python named ipyflow : github dot com/ipyflow/ipyflow

I’m pretty sure this kind of feature could be great for Scilab also.