Mathics and Nebo
Subtitle: Symbolic Mathematics and AI Handwriting Recognition
I’ve been playing around with a couple of fun math toys recently, Mathics and Nebo. Mathics is a free, open-source symbolic calculator. Nebo is a note-taking app for laptops, tablets, and smartphones with stylus inputs, and it can accept and understand mathematics. Nebo is free for the iPad, ($10 on Windows), and you can try Nebo here.
# Mathics
The description of Mathics says,
Mathics is a free, open-source general-purpose computer algebra system featuring Mathematica®-compatible syntax and functions.
It relies on Python libraries, in particular, Sympy for symbolics, mpmath for arbitrary precision floating-point arithmetic, MathJax to render equations, and three.js and Asymptote to create graphics. Mathics isn’t as powerful as Mathematica, but the price is much better. Here’s a problem we can try in Mathics,
Find .
Notice that everything in the denominator of the first fraction is identical to , so the equation can be rewritten as
Using the quadratic formula,
In Mathics, the symbol for the imaginary unit is , so to solve for type
followed by Ctrl-Enter
to get the solution. Hmmm. These solutions are correct, but not informative. The solution for has an in it.
The roots of a polynomial are the values of that make the polynomial zero, in this case, . An degree polynomial will always have roots, even if some are complex (real + imaginary parts). Suppose the two roots to this polynomial are and , which means that
Putting this into Mathics and collecting terms,
Then and . Solving these two equations simultaneously in Mathics,
which is correct.
To open a help window in Mathics, click on the ?
in the upper right corner. Complete documentation is available online here.
# Nebo
MyScript Nebo uses AI to interpret handwriting. If you have a tablet or laptop that accepts input from a stylus, Nebo will convert your handwritten notes to text. With Nebo, you can draw diagrams, and it will clean them up:
You can insert images into a document, and draw freehand sketches. I tend to write ideas down on a pad of paper, and the next great idea goes on the next empty page in the pad. My house is cluttered with pads. What was this one all about?
So I thought Nebo might be useful in organizing and cleaning up all my scribblings. Here’s an example:
On the left are the original hand-written equations. After tapping twice on the screen, Nebo converted everything to MathJax format. I had to fix three errors - two of the lower case ’s had been changed to upper case, and one of the ’s was interpreted as an . Other than that, Nebo got it exactly right on the first try.
If you copy a section of math in Nebo, you can paste it into a markdown editor like this.
Nebo includes the formatting characters
\begin{aligned}
x^{2}+bx+c&=0\\
\left( x-r\right) \times \left( x-s\right) &=x^{2}-\left( r+s\right) x+rs\\
b&=-\left( r+s\right) \\
c&=rs\\
u&=\dfrac{r+s}{2}\\
v&=u-r=s-u\\
r&=u-v,s=u+v\\
rs&=\left( u-v\right) \times \left( u+v\right) =u^{2}-v^{2}
\end{aligned}
I added ampersands before the equal signs to align each equation with the one above it. Nebo did all of the rest, including the \begin{aligned}
and \end{aligned}
.
Getting back to the math, to find the roots of the quadratic polynomial , you might remember the quadratic formula,
If you have the form , divide by and calling the new , and the new , which has the same roots.
If we call the roots and , then the plot of will cross the axis at and , and can be written as
Expanding the terms on the right,
which means that and .
Let’s call the midpoint between and the point . Then
or
Since is the midpoint, the distance from to is the same as the distance from to , so let’s call that distance . Another way to express this is and . Solving for in the first equation, Since then
After calculating in terms of , we can get from and ,
To recap, first find the midpoint of the unknown roots which will be at , and then get the distance to the roots which is . The roots will be . So, now you can follow all of my chicken-scratching in Nebo.
For example, suppose , the plot in the figure above drawn in GeoGebra. Then and
So, the roots are
One more Nebo trick - write the equation with an equal sign at the end like this:
Double-tap, and you’ll get a neatly written equation with the solution!
Erase the , replace it with a minus sign, and double-tap to get the other root . Nebo doesn’t do complex math, so we wouldn’t be able to solve the problem done earlier in Mathics, but for quick calculations, it’s pretty neat!
A nice introduction to Nebo is available from Paperless and Vojislav Dimitrijevic of My Deep Guide reviews the mathematical capabilities here.
# Obsessed with Obsidian
Obsidian is the electronic version of my pads of paper. Obsidian is a markdown editor and a knowledge database of your ideas linked together. Upmath shows how to get started using LaTeX in Markdown files to write equations. Help is available by clicking on the ?
in the lower left-corner, which opens a new pop-up window. An outline appears in the left panel, and document links are shown in the right panel.
The graphical view of help looks like this:
Click on Open another vault
to switch to your files. To extend the capabilities of Obsidian there are both core plugins and community plugins. The Sweet Setup blog lists some of their favorite plugins, and LibHunt lists the top community projects.
# SyncThing
I switch between the desktop computer and laptop frequently, depending on whichever is the most convenient at the moment. But, how should I keep files synchronized between the two? Copying back and forth whenever I modify a file on one seemed tedious.
This is where SyncThing comes to the rescue. It continuously synchronizes files between any number of your computers, all in the background, using your home network. Take a look at the “Getting Started” page, and online documentation. After installation, all you need to do is identify your computers and the folders you’d like to synchronize. After that, the software keeps everything up-to-date.
For Windows users, SyncTrayzor is a tray utility for SyncThing.
After installing SyncThing on both computers, I realized I needed to have both running simultaneously to be able to sync, but I almost always shut down one when working on the other. The solution is that SyncThing is available for both Android and iOS phones, using the same convenient GUI.
Since my phone is almost always on, it keeps the latest version of all the files from whichever computer I’m currently using. I’ve even found that Python code is automatically reloaded in the Spyder editor, so long as I’ve remembered to save my work.
Now, with the phone acting as an intermediary, SyncThing makes switching between computers indistinguishable from magic.
# Mathics Installation
Installing Nebo, Obsidian, and SyncThing is just a matter of following their instructions. Mathics is slightly more complicated but still easy. Here are the steps I used:
- Start Anaconda Powershell as administrator. I use Anaconda Python.
- Check python version: python --version
- Check pip version: pip --version
- Install Mathics: pip install Mathics-omnibus[full]
- Type: mathicsserver --help to check the installation
- Start mathics: mathicsserver
- In your browser (Chrome or Firefox) go to localhost:8000
- Save the mathics.png image from https://github.com/Mathics3
- Convert the image to mathics.ico using https://www.icoconverter.com/
- Make a batch file called mathics.bat containing the single command mathicsserver
- Create a desktop icon linked to mathics.bat, and change the icon to mathics.ico
- Click on the desktop icon to start Mathics, and type localhost:8000 in the address bar. Drag to the bookmarks bar.
Running Mathics from now on requires two steps - clicking on the icon to start the server followed by clicking the link to localhost:8000.