Skip to main content

Getting Started

Install Epsil and run your first symbolic program in five minutes.

Experimental

Epsil is experimental. Its syntax and behavior may change between releases.

Install

Epsil is included with the Compute Engine package:

npm install @cortex-js/compute-engine

The package installs an epsil command. During development, run the project-local command through npx.

Try the REPL

Start an interactive session:

npx epsil

Enter a declaration, then use it in another expression:

epsil> let x = 5
5
epsil> x^2
25

The REPL keeps declarations and assignments between inputs. Enter .help for the available commands and .exit when you are done.

Run a Source File

Save this program as squares.epsil:

square(x) = x^2
Map(1..5, square)

Run it:

npx epsil squares.epsil

The result is:

[1,4,9,16,25]

The conventional file extension is .epsil.

Work Symbolically

Epsil uses the Compute Engine, so expressions remain exact and symbolic by default:

⌘/Ctrl + Enter

Use N() when you want a numeric approximation:

⌘/Ctrl + Enter

Embed Epsil in JavaScript

Import the experimental Epsil entry point, create a ComputeEngine, then execute source text:

import {
ComputeEngine,
executeEpsil,
} from "@cortex-js/compute-engine/epsil";

const ce = new ComputeEngine();
const { value, diagnostics } = executeEpsil(
ce,
"factorial(n) = 1 if n <= 1 else n * factorial(n - 1)\nfactorial(10)"
);

if (diagnostics.length > 0) console.error(diagnostics);
console.log(value.toString()); // 3628800

Calls made with the same ComputeEngine share its top-level declarations, which is useful for notebook cells and other stateful sessions. Create a fresh engine when you want an isolated program.

Where to Go Next