LinuxCommandLibrary

eva

Evaluate arithmetic expressions

TLDR

Run the calculator in interactive mode

$ eva
copy

Calculate the result of an expression
$ eva "[(1 + 2) * 2 ^ 2]"
copy

Calculate an expression forcing the number of decimal places to 5
$ eva --fix [5] "[5 / 3]"
copy

Calculate an expression with sine and cosine
$ eva "[sin(1) + cos(1)]"
copy

SYNOPSIS

eva [options] expression

PARAMETERS

-h, --help
    Display usage information and exit

-v, --version
    Output version information and exit

-d NUM, --decimals NUM
    Set number of decimal places (default: 10)

-s NUM, --seed NUM
    Set seed for random number generator

DESCRIPTION

Eva is a lightweight, portable command-line tool for evaluating mathematical expressions directly in the terminal. Implemented as a pure POSIX-compliant shell script, it uses awk for parsing and computation, ensuring broad compatibility across Unix-like systems without external dependencies beyond standard tools.

It supports a rich set of operations: basic arithmetic (+, -, *, /, %, ^), trigonometric functions (sin(), cos(), tan(), and their inverses/hyperbolic variants), logarithms (ln(), log(), log10()), roots (sqrt(), cbrt()), absolute value (abs()), GCD/LCM, factorial (!), constants like pi and e, and random numbers (rand()). Variables can be assigned with = for complex calculations, e.g., eva 'x=5; x^2 + sin(pi/2)'.

Precision is customizable via options, defaulting to 10 decimal places. Eva excels in scripting, quick computations, and interactive use, outperforming heavier alternatives like bc in simplicity while matching functionality. Its tiny footprint (single script) makes it ideal for embedded systems or minimal environments. Output is clean, with optional formatting. Widely praised for speed and extensibility via awk tweaks.

CAVEATS

Relies on awk and basic shell features; may vary slightly in output on non-POSIX systems. No interactive mode; expressions must be single-line. Limited to awk-supported functions.

SUPPORTED FUNCTIONS

Math: sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, ln, log, log10, sqrt, cbrt, abs, gcd, lcm, ! (factorial)
Constants: pi, e
Other: rand()

EXAMPLES

eva '2+3*4' → 14
eva 'sin(pi/2)' → 1
eva 'x=10; sqrt(x)' → 3.16227766017
eva -d 4 'log10(1000)' → 3.0000

HISTORY

Developed by nerdypepper (Alikabbaj) starting in 2020 as a minimal calculator. First public release on GitHub in 2021, with ongoing updates for new functions and portability fixes. Gained popularity in minimalism communities for its shell-script purity.

SEE ALSO

bc(1), dc(1), awk(1), expr(1)

Copied to clipboard