Free MathCAD alternative for Linux
Computing Competency
![© Lead Image © donnastern , 123RF.com © Lead Image © donnastern , 123RF.com](/var/linux_magazin/storage/images/issues/2023/269/smath/123rf_114070522_steampunk_abstract_donnasterns_resized.png/819289-1-eng-US/123rf_114070522_Steampunk_abstract_donnasterns_resized.png_medium.png)
© Lead Image © donnastern , 123RF.com
Present complex equations with intermediate steps, graphics, plots, and results in SMath.
University students in engineering often have assignments in which they must show their work step-by-step with sample calculations. Although Excel and Python are useful for advanced calculations, they can't present complex equations formally in a report.
MathCAD [1] is a good package for writing engineering reports. The tool offers a workbook interface that allows you to enter complex equations in a readable format, along with a rich function library, programming interface, graphics, and plots. Unfortunately, MathCAD isn't supported in Linux, and it is generally out of the budget for students or casual users. As an alternative, SMath is a great free option that works in Linux, macOS, and Windows.
In this article I introduce SMath and show you some of the useful features that I expect to use in my next engineering term. I also look at an SMath example that solves a typical high school or first-year university math problem.
Getting Started
The SMath installation files reside on the project's website [2]. To install the software, the Mono development environment needs to be loaded first. In Debian/Raspbian/Ubuntu systems, enter:
sudo apt install mono-devel
In the next step, copy the SMath installation files to a local directory on your laptop and run the SMath desktop:
# run SMath Studio in Linux: ./smathstudio_desktop_mono
SMath Studio has a side panel of common functions and symbols (Figure 1). All the functions are listed in the Insert Function (fx) dialog box.
Equations, Variables, and Units
SMath lets you create complex calculations from the side panel (Figure 1) or with keyboard shortcuts. Complex equations can be modified with the arrow keys to move the cursor between elements (Figure 2).
SMath Sheets calculate from top left to bottom right, so it is important to define a variable before it is used. A variable is defined with :=
, and the results of a calculated value are displayed with the equals sign (=
).
To add units to a variable, type a single quote ('
) before entering the unit, or you can choose from a list of units (Figure 3). If a calculation has mixed units, SMath automatically manages the conversion between units (Figure 4).
To make things a little more presentable, SMath shows variables, calculations, and results in black and units in blue, although this feature is adjustable. The final results of a calculation can be presented in fractions, unit conversions, or simply the numeric value.
Solutions
SMath also supports useful features such as interface widgets and plotting, as well as conditional code. One problem that regularly needs to be solved in high school and many first-year university courses is to find x intercepts and the area under a parabola defined by a quadratic equation. The next example solves this problem and highlights some of the key features built into SMath.
The first step in solving this problem is to define the input variables. User interfaces such as adjustable sliders can be added from the Insert menu in the toolbar (Figure 5). Slider widgets define and toggle variables (Figure 6).
Plotting a parabola is a quick way to check the number of x intercepts for an equation. To add a plot, use Insert | Plot | 2D (Figure 7). Once a plot is dropped onto a workbook it can be resized and repositioned. For this example, the plot is configured to show the f(x) quadratic equation.
You can quantitatively find the number of x intercepts in two ways (Figure 8): by manually solving the quadratic formula for x when y=0, or with the SMath solve(2)
function. To insert this function, type solve, then press the Tab key once the dropdown menu displays solve(2). To find the area under the curve, the results of the solve
function should be defined as a new variable (e.g., MyRoots
).
The solve(2)
function returns one or two x intercepts where the curve touches or crosses the x-axis. If you don't change your settings to Calculation | On error | Continue (Figure 9), the logic will be interrupted if a curve does not cross the x-axis.
Added logic can handle special cases. To solve for the area under the curve, I used the if
statement then checked for valid roots (Figure 10). An IsDefined
function checks whether the MyRoots variable is valid (i.e., has roots).
If roots are found, the limits are passed to an integral function to calculate the area. (Integral and derivative functions are found in the Functions side panel.) If no roots are found, the string "Equation doesn't cross axis"
is passed to the area
variable.
Figure 11 shows the final SMath worksheet example, with the interface widgets and plotting and conditional code that find the x intercepts and area under a parabola with the quadratic equation.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.
-
SUSE Offers CentOS 7 Support with Liberty Linux Lite
SUSE's Liberty Linux support offering now includes CentOS 7, which means businesses won't be forced to migrate those servers for some time.
-
Ubuntu's App Center Finally Supports Local Installs Again
If you regularly download .deb files and would prefer a GUI method of installing, Ubuntu has your back.
-
AlmaLinux Now Supports Raspberry Pi 5
If you're looking to create with the Raspberry Pi 5 and want to use AlmaLinux as your OS, you're in luck because it's now possible.
-
Kubuntu Focus Releases New Iterations of Ir14 and Ir16 Laptops
If you're a fan of the Kubuntu Focus laptops or have been waiting for the right time to purchase one, that time might be now.
-
NixOS 24.05 Is Ready for Prime Time
The latest release of NixOS (Uakari) has arrived and offers its usual reproducible, declarative, and reliable goodness.
-
Linux Lite 7.0 Officially Released
Based on Ubuntu 24.04 and kernel 6.8, Linux Lite version 7 now offers more options than ever.
-
KaOS Linux 2024.05 Adds Bcachfs Support and More
With updates all around, KaOS Linux now includes support for the bcachefs file system.
-
TUXEDO Computers Unveils New Iteration of the Stellaris Laptop Line
The Stellaris Slim 15 is the 6th generation and includes either an AMD or Intel CPU