Check an introductory post about Wolfram & Raspberry Pi 5 here: https://community.wolfram.com/groups/-/m/t/3558592​
Part 1 of this series here: https://community.wolfram.com/groups/-/m/t/3577991​
Part 3 of this series here: https://community.wolfram.com/groups/-/m/t/3578728
Discover how the Raspberry Pi 5 turns into a full STEM lab with free Mathematica. From real-time sensor dashboards to image processing, neural networks and stunning math art, this guide empowers students, teachers, and parents to explore, invent, and visualize science and engineering like never before. CITATION: Bart ter Haar Romeny, Raspberry Pi 5 + Mathematica: A STEM Creativity Powerhouse, Wolfram Technology Conference 2025. https://www.wolfram.com/events/technology-conference/2025/
All applications of this presentation are executed on a Raspberry Pi 5 with 16 GB and 256 GB NVMe.

Compile

MathArt - swimming jellyfish in an aquarium

A tribute to Tom Wickham - Jones, (Director of Kernel Technology at Wolfram Research)
Source: https://community.wolfram.com/groups/-/m/t/3320126, 14-11-2024
Full dedicated post of this example: https://community.wolfram.com/groups/-/m/t/3558969
This example is taken from the Wolfram Community posts, where Vitaliy Kaurov, Director of Engagement at Wolfram Research, discovered a nice set of mathematical art implementations by @yuruyurau written in JavaScript. He took the example to show how ChatGPT could transfer the Java code into Wolfram Language.
As the Raspberry Pi 5 is a tiny computer, we go make some adjustments to make it faster and suitable for our RPI5.
But above that, this notebook will learn you a nice set of programming paradigms.
Here is the original mathematical function:
In[]:=
a[x_, y_, t_] := Module[{k, e, d, q, c},​​ k = x/8 - 25;​​ e = y/8 - 25;​​ d = (k^2 + e^2)/99;​​ q = x/3 + k/Cos[5y] Sin[d^2 - t]/2;​​ c = d/2 - t/8;​​ {​​ q*Sin[c] + e*Sin[d + k - t] + 200,​​ (q + y/8 + d*9)*Cos[c] + 200​​ }​​]
In the code the math formula is in a nested form, and it is difficult to see what happens. The resulting formula is quite complicated. So let’s view it in the traditional (text book) form:
In[]:=
a[x,y,t]//TraditionalForm
Out[]//TraditionalForm=
-
y
8
-25sint+
1
99
-
2
x
8
-25
-
2
y
8
-25
-
x
8
+25-sin
t
8
+
1
198
-
2
x
8
-25
-
2
y
8
-25
x
3
-
1
2
x
8
-25sec(5y)sint-
2

2

x
8
-25
+
2

y
8
-25

9801
+200,cos
t
8
+
1
198
-
2
x
8
-25
-
2
y
8
-25
-
1
2
x
8
-25sec(5y)sint-
2

2

x
8
-25
+
2

y
8
-25

9801
+
1
11
2
x
8
-25
+
2
y
8
-25
+
x
3
+
y
8
+200
Pretty amazing indeed. It is a function that gives as output a pair of values at coordinates
{x,y}
at time
t
. The input consists of three variables,
x
and
y
for the position and
t
for the time. We go make a canvas of
400x400
positions (pixels), and we go scan this canvas for all positions 100 ≤ x ≤ 299 in steps of 1, and 99 ≤ y ≤ 299 in steps of 5.
Let us inspect what the function
a[x,y,t]
actually gives. Here is the value of the first time point at
t=0
at the starting position
{x=100,y=99}
:
In[]:=
a[100,99,0]
Out[]=
200+
101
8
Sin
58999
6336
+Sin
20201
12672

100
3
-
25
4
Sec[495]Sin
408080401
40144896
,200+Cos
20201
12672

157139
2112
-
25
4
Sec[495]Sin
408080401
40144896

Oeps. We immediately see the problem: as Mathematica works with symbolic expressions when exact numbers (like integers) are involved, this is an expensive operation, both in memory use and time. The situation is sped up when we take real numbers. This is simply done by converting an integer by adding a numerical point after it, so
t=0
becomes
t=0.
or by using the numerical value function N[0].
In[]:=
a[100,99,0.]
Out[]=
{256.054,197.765}
We only have to specify one real to force Mathematica to process the formula numerically:
In[]:=
a[100.,99,0]
Out[]=
{256.054,197.765}
Here is a timing experiment, to calculate the complete jellyfish image at 10 time moments:
In[]:=
time=First@Timing[pts=Table[a[x,y,t],{x,99,299,5},{y,100,299},{t,0,9}];]
Out[]=
4.58342
And with reals:
In[]:=
timeNumerical=First@Timing[pts=Table[a[x,y,t],{x,99,299,5},{y,100,299},{t,0.,9.}];]
Out[]=
3.34466
A bit of gain.
Can we do more by compiling the function? Let us do the exercise, and learn how compilation works.
When a function is compiled, the code is made into the lowest possible machine code, and with pre-specified number types. See for more details the Documentation.
The Compile function is easy to build. For example, f = Compile[{{x,_Real},{y,_Real}},x^2+4 y^2] gives the function f[x,y] that calculates
2
x
+4
2
y
. We need to give the type of the internal representation of the variables (both
x
and
y
are Real), and do that first within the Compile function brackets.
We convert the formula to InputForm so it can be used as code in Compile:
In[]:=
a[x,y,t]//InputForm
Out[]//InputForm=
{200 - (-25 + y/8)*Sin[25 + t - x/8 +
(-(-25 + x/8)^2 - (-25 + y/8)^2)/99] -
Sin[t/8 + (-(-25 + x/8)^2 - (-25 + y/8)^2)/198]*
(x/3 - ((-25 + x/8)*Sec[5*y]*
Sin[t - ((-25 + x/8)^2 + (-25 + y/8)^2)^2/9801])/2),
200 + Cos[t/8 + (-(-25 + x/8)^2 - (-25 + y/8)^2)/198]*
(x/3 + ((-25 + x/8)^2 + (-25 + y/8)^2)/11 + y/8 -
((-25 + x/8)*Sec[5*y]*
Sin[t - ((-25 + x/8)^2 + (-25 + y/8)^2)^2/9801])/2)}
We copy it into the Compile body, also changing the non-exponent integer numbers to Reals (by adding the numerical dot):
In[]:=
aCompiled=Compile[{{x,_Real},{y,_Real},{t,_Real}},​​{200.-(-25.+y/8.)*Sin[25.+t-x/8.+(-(-25.+x/8.)^2-(-25.+y/8.)^2)/99.]-Sin[t/8.+(-(-25.+x/8.)^2-(-25.+y/8.)^2)/198.]*(x/3.-((-25.+x/8.)*Sec[5.*y]*Sin[t-((-25.+x/8.)^2+(-25.+y/8.)^2)^2/9801.])/2.),200.+Cos[t/8.+(-(-25.+x/8.)^2-(-25.+y/8.)^2)/198.]*(x/3.+((-25.+x/8.)^2+(-25.+y/8.)^2)/11.+y/8.-((-25.+x/8.)*Sec[5.*y]*Sin[t-((-25.+x/8.)^2+(-25.+y/8.)^2)^2/9801.])/2)}]
Out[]=
CompiledFunction
Argument count: 3
Argument types:
{_Real,_Real,_Real}

And the explanation: it is a function of three arguments, and we need to specify the type of both the arguments and the internally used variables. The typing for the arguments is done at the very beginning: a list (specified by the curly brackets) of lists: {{x,_Real},{y,_Real},{t,_Real}}. The underscore _ means ‘any value’, and _Real means ‘any value, typed as Real’. Then the main body specifies the formula. The typing of internally used variables is done after the main code (see the documentation of Compile), but we don’t have them here. They would have been specified after a comma after the main code, in the same format as the argument types.
The proof of the pudding is in the eating, so here is the timing test, for 10 frames:
In[]:=
timeCompiled=First@Timing[pts=Table[aCompiled[x,y,t],{x,99,299,5},{y,100,299},{t,0,9}];]
Out[]=
0.076613
How much faster?
In[]:=
timeNumerical
timeCompiled
Out[]=
43.6566
Quite nice!
A remark: why not put the original code in the Compile function? Well, as this code is quite nested, each time a complicated calculation has to be done for each point. The strength of Mathematica is that it can do this expansion of the nesting once, symbolically.
Here is the timing result if we put the nested code into the Compile function:
In[]:=
aCompiledNested=Compile[{{x,_Real},{y,_Real},{t,_Real}},​​k=x/8.-25.;​​e=y/8.-25.;​​d=(k^2.+e^2.)/99.;​​q=x/3.+k/Cos[5.y]Sin[d^2.-t]/2.;​​c=d/2.-t/8.;​​out={​​q*Sin[c]+e*Sin[d+k-t]+200.,​​(q+y/8.+d*9.)*Cos[c]+200.​​};​​out,​​{{k,_Real},{e,_Real},{d,_Real},{q,_Real},{c,_Real},{out,_Real,1}}]
Out[]=
CompiledFunction
Argument count: 3
Argument types:
{_Real,_Real,_Real}

In[]:=
timeCompiledNested=First@Timing[pts=Table[aCompiledNested[x,y,t],{x,99,299,5},{y,100,299},{t,0,10}];]
Out[]=
2.81588
In[]:=
timeNumerical
timeCompiledNested
Out[]=
1.18779
So that could hardly beat Mathematica’s own implementation ...

The drawing function:

Take a background image, e.g. an aquarium, preferably with dark appearance, so the white dots of the jellyfish stand out nicely:
In[]:=
bg=ImageResize[ImageTake[Import["https://thumbs.dreamstime.com/b/saltwater-full-corals-mixed-aquarium-one-most-beautiful-addition-home-coral-reef-aquarium-tank-scene-fishes-118136040.jpg"],{All},{254,800}],{400,400}]
Out[]=
Here is the interactive motion of the jellyfish:
Click the + to the right of the slider to show the controls, and hit the play button.

Geogebra with the Wolfram Language - write your own apps easily

Circle from 3 points by perpendicular bisectors

According to German Wikipedia, GeoGebra had about 30 million registered users across 190 countries by 2017, increasing to around 100 million users in 195 countries by December 2021.
On Android, GeoGebra apps have amassed approximately 30 million total installs across its suite.
To find the equation for a circle, going through three points, we use the fact that two bisectors (the line halfway and normal to the line connecting a pair of points) intersect in the center point of the circle.
Carefully try to understand the code below, and play with the resulting animated figure.
You can turn the bisectors on and off in the display.

How to plot a perpendicular bisector?

CITE THIS NOTEBOOK

Wolfram & Raspberry Pi 5 — Part 2: compilation and mathematical visualization​
by Bart ter Haar Romeny​
Wolfram Community, STAFF PICKS, November 19, 2025
​https://community.wolfram.com/groups/-/m/t/3578212