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 + 3results in5) - Subtraction:
-(e.g.,5 - 2results in3) - Multiplication:
*or·(e.g.,4 * 3results in12) - Division:
/(e.g.,10 / 2results in5) - Exponentiation:
^(e.g.,2 ^ 3results in8)
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
MATHf(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 in3) - Sine:
sin(x)(e.g.,sin(π/2)results in1) - Cosine:
cos(x)(e.g.,cos(0)results in1) - Tangent:
tan(x)(e.g.,tan(π/4)results in1) - Logarithm:
log(x)is the $\ln(x)$. You can also uselog(x, base), which gives $\log_{base}x$
Advanced Functions
For more complex calculations, Voima Toolbox also supports:
- Absolute Value:
abs(x)(e.g.,abs(-5)results in5) - Power:
pow(x, y)(e.g.,pow(2, 3)results in8) - Exponent:
exp(x)(e.g.,exp(1)results ine)
Constants
Voima Toolbox provides a set of useful constants:
- Pi:
piorπ(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 * 2results in13 - Using Variables:
x^2 + y^2forx = 3andy = 4results in25 - Mathematical Functions:
sqrt(x^2 + y^2)forx = 3andy = 4results in5 - Logical Operations:
x > 0 && y < 10forx = 5andy = 3results intrue
Common Mistakes and How to Avoid Them
-
Mismatched Parentheses: Always check that every opening parenthesis has a corresponding closing parenthesis.
- Example: Use
(2 + 3) * 4instead of2 + 3 * 4).
- Example: Use
-
Undefined Variables: Ensure all variables are defined before using them in an expression.
- Example: Define
xbefore usingf(x) = x^2.
- Example: Define
-
Incorrect Syntax: Use the correct syntax for functions and operators.
- Example: Use
sqrt(x)instead ofsquareRoot(x).
- Example: Use
By following these guidelines, you can effectively use Voima Toolbox for a wide range of mathematical calculations.