Knot is a minimal, custom-built language that lets you write mathematical expressions and instantly see their graph.
It’s designed to be simple, lightweight, and fun to use — just type, run, and plot!
Make sure the following are installed on your system:
makegnuplotgccandg++
You can install them using:
🟢 Ubuntu / Debian (including WSL):
sudo apt update
sudo apt install build-essential gnuplot🟣 Arch-based:
sudo pacman -S base-devel gnuplot🪟 Windows (via Chocolatey):
If you're on Windows, you can install all dependencies with Chocolatey.
Open PowerShell as Administrator and run:
choco install mingw make gnuplot -yFirst, clone the repo:
git clone https://github.com/parv141206/knotThen navigate to the project’s root directory and run the build script:
./build.shThis will compile the project and generate the knotc executable inside the build directory.
To make knotc accessible globally from the terminal:
🔹 On Linux / WSL:
Add the build folder to your PATH:
echo 'export PATH="$PATH:/path/to/knot/build"' >> ~/.bashrc
source ~/.bashrc🔹 On Windows:
Add the full path to the build folder (e.g., C:\Users\YourName\knot\build) to your system PATH via Environment Variables.
Knot follows a very minimal custom syntax.
Write the equation(s) you want to plot in a .knot file.
Here’s an example inside main.knot:
plot y = sin(x)
Now plot it using:
knotc main.knotBoom — this should open a Gnuplot graph window with your plot!
Knot’s syntax is intentionally clean and beginner-friendly — like Markdown, but for math graphs.
Here’s how it works:
-
Every plot starts with the
plotkeyword, followed byy =and your equation.Example:
plot y = x -
After the
=sign, you can write any math expression involvingx.
(Noy = mx + bconfusion — just write it and go!) -
Currently,
xis the only variable supported — but don’t worry, a more dynamic version is on the way! -
Supported functions include
sin,cos,tan,log,exp, and many more! -
No semicolons. No boilerplate. Just math.
-
You can stack multiple
plotlines to layer graphs on top of each other — they’ll all show up on the same canvas.Example:
plot y = sin(x) plot y = cos(x)This will render both the sine and cosine curves in one go!
🧠 TL;DR:
plot y = <math stuff with x> — do this as many times as you want. Gnuplot handles the rest!
Currently there are 2 options which you can pass,
--step Set the increment in x. Default: 0.1
--end-bound Set the max absolute value of x. Default: 10.0
For example
knotc ./main.knot --step 0.01 --end-bound 3
The following functions are currently supported in Knot:
| Function | Arity | Description |
|---|---|---|
sin(x) |
1 | Sine of x (in radians) |
cos(x) |
1 | Cosine of x |
tan(x) |
1 | Tangent of x |
cosec(x) |
1 | Cosecant of x |
sec(x) |
1 | Secant of x |
cot(x) |
1 | Cotangent of x |
sqrt(x) |
1 | Square root of x |
log(b, x) |
2 | Logarithm of x with base b (e.g., log(2, 8) → 3) |
ln(x) |
1 | Natural logarithm (base e) of x |
pow(b, e) |
2 | b raised to the power e (e.g., pow(2, 3) → 8) |
abs(x) |
1 | Absolute value of x |
exp(x) |
1 | e raised to the power x |
floor(x) |
1 | Largest integer ≤ x |
ceil(x) |
1 | Smallest integer ≥ x |
📝 Arity just means the number of arguments the function takes.
Sosin(x)has arity 1, whilelog(b, x)has arity 2.
More functions will be added soon — feel free to open an issue if you have requests!
- Arctic Monkeys album cover
plot y = sin(x) * cos(20*x)
Options: --step 0.01 --end-bound 3
- Gaussian Curve
plot y = exp(-x * x)
Options: --step 0.01 --end-bound 3
- Damped Oscillation
plot y = exp(-x * x) * cos(10 * x)
Options: --step 0.01 --end-bound 3
- Rollercoaster
plot y = sin(x) + sin(2 * x) / 2 + sin(3 * x) / 3



