Márcio Neto

Last modified:

Guide to Using Mathematical Expressions with Voima Toolbox

Voima Toolbox enables you to perform a wide range of mathematical calculations using expressions using the following calculation blocks in the flowsheet editor:

  • Function1
  • Function2
  • Function3

This guide will help you understand what types of expressions are allowed and how to use them effectively.

Basic Arithmetic Operations

Voima Toolbox supports all standard arithmetic operations, including:

  • Addition: + (e.g., 2 + 3 results in 5)
  • Subtraction: - (e.g., 5 - 2 results in 3)
  • Multiplication: * or · (e.g., 4 * 3 results in 12)
  • Division: / (e.g., 10 / 2 results in 5)
  • Exponentiation: ^ (e.g., 2 ^ 3 results in 8)

Using Variables

Variables allow you to represent numbers or results within your expressions. Voima Toolbox supports the use of variables such as x, y, and z.

Example

f(x, y) = x^2 + 2*y

Here, x and y are variables. You can assign values to them and calculate the result based on the given expression.

Mathematical Functions

Voima Toolbox includes a wide range of built-in mathematical functions:

  • Square Root: sqrt(x) (e.g., sqrt(9) results in 3)
  • Sine: sin(x) (e.g., sin(π/2) results in 1)
  • Cosine: cos(x) (e.g., cos(0) results in 1)
  • Tangent: tan(x) (e.g., tan(π/4) results in 1)
  • Logarithm: log(x) is the ln(x)\ln(x). You can also use log(x, base), which gives logbasex\log_{base}x

Advanced Functions

For more complex calculations, Voima Toolbox also supports:

  • Absolute Value: abs(x) (e.g., abs(-5) results in 5)
  • Power: pow(x, y) (e.g., pow(2, 3) results in 8)
  • Exponent: exp(x) (e.g., exp(1) results in e)

Constants

Voima Toolbox provides a set of useful constants:

  • Pi: pi or π (approx. 3.14159)
  • Euler's Number: e (approx. 2.71828)

Logical and Comparison Operators

Logical and comparison operators allow you to create expressions that evaluate to true (always converted to 1) or false (always converted to 0).

  • Greater Than: > (e.g., x > 2)
  • Less Than: < (e.g., x < 5)
  • Equal To: == (e.g., x == 3)
  • Not Equal To: != (e.g., x != 4)
  • And: && (e.g., x > 2 && y < 5)
  • Or: || (e.g., x < 1 || y > 3)

Examples of Expressions

  • Simple Arithmetic: 3 + 5 * 2 results in 13
  • Using Variables: x^2 + y^2 for x = 3 and y = 4 results in 25
  • Mathematical Functions: sqrt(x^2 + y^2) for x = 3 and y = 4 results in 5
  • Logical Operations: x > 0 && y < 10 for x = 5 and y = 3 results in true

Common Mistakes and How to Avoid Them

  • Mismatched Parentheses: Always check that every opening parenthesis has a corresponding closing parenthesis.

    • Example: Use (2 + 3) * 4 instead of 2 + 3 * 4).
  • Undefined Variables: Ensure all variables are defined before using them in an expression.

    • Example: Define x before using f(x) = x^2.
  • Incorrect Syntax: Use the correct syntax for functions and operators.

    • Example: Use sqrt(x) instead of squareRoot(x).

By following these guidelines, you can effectively use Voima Toolbox for a wide range of mathematical calculations.