Crate taschenrechner[][src]


A CAS is an advanced symbolic calculator. It can evaluate, simplify, differentiate, integrate and solve algebraic expressions.

use cas::prelude::*;

fn main() {


Warning: This is not yet feature-complete. See libqalculate for a better alternative.

  • REPL interface
  • Lex operators, functions, symbols, deciaml numbers
  • Parse expressions of infix notation into a expressions tree
  • Define variables and functions
  • Simplify expressions
  • Evaluate expressions to single numbers
  • Comprehensive notation-error messages


  • Arbitrary-precision arithmetic
  • Integrate, differentiate expressions
  • Solve single- and multi-variable equations / inequalities


The current eval is not very sophisticated. It is functional, but can’t simplify any expressions, if a subexpression remains unresolved.


This crate comes with an interactive comand-line-interface: Read-Eval-Print-Loop.

Built-in functions and constants

(for a full complete list see default_env.txt)

  • π (pi), τ (tau), e (eurler’s number), inf (infinity), nan (not a number)
  • trigonometric functions: sin, cos, tan, their inverse and hyperbole
  • abs, ceil, floor, trunc, fract

How to build see Cargo for Rust


Also see my blog post!

Algebraic expressions

4.3 - π^2 = sin y is an algebraic expression. It consists of atoms (4.3, π, 2, y) and operators (-, ^, =, sin). Operators manipulate atoms. We normally write such expressions in infix-notaion, where one has to know the precedence and associativity of an operator. The exponent (^) must be evaluated before the the substraction (-), evon though it appears later. To evaluate the expression linearly, it has to be converted into polish noation, which is basicly a single function call of function calls (= - 4.3 ^ π 2 sin y).

Lexer and parser

To evaluate the string of an expression, it undergoes 3 steps:

  • Lexer the string is split up into tokens (4.3, -, π, ^, 2, =, sin, y)
  • Parser the stream of tokens will be ordered into polish notation
  • Eval the expression tree can now be evaluated recursively



The prelude module contains all the types to get you started.