Calculation Utilities
The following are helpful utilites for building calculations using the LatexExpr library.
- ABRACKETS(*args)
- Wraps any calculation expression or variable in angle brackets in the calculation report. - Parameters
- args (Variable, Input, Calculation) – 1 objects for angle brackets ( <arg> ) 
 - >>> v = Variable('v', 2) >>> Calculation('result', CBRACKETS(v + 1)) Calculation report will show --> result = <v + 1> = <2 + 1> = 3 
- ABS(*args)
- Used to get the absolute value of an object. - Parameters
- args (Variable, Input, Calculation) – 1 object for absolute value ( |arg0| ) 
 - >>> v = Variable('v', -2, 'in') >>> c = Calculation('result', ABS(v), 'in') Calculation report will show --> result = |v| = | -2 in | = 2in 
- BRACKETS(*args)
- Alias for - RBRACKETS()
- CBRACKETS(*args)
- Wraps any calculation expression or variable in curly brackets in the calculation report. - Parameters
- args (Variable, Input, Calculation) – 1 objects for curly brackets ( {arg} ) 
 - >>> v = Variable('v', 2) >>> Calculation('result', CBRACKETS(v + 1)) Calculation report will show --> result = {v + 1} = {2 + 1} = 3 
- COS(*args)
- Used to get the trigonometric cosine of an object (using radians). - Parameters
- args (Variable, Input, Calculation) – 1 objects for cosine operation ( cos(arg0) ) 
 - >>> c = Calculation('result', COS(PI / 3)) Calculation report will show --> result = cos(pi / 3) = cos(3.142 / 3) = 0.5 
- COSH(*args)
- Used to get the hyperbolic cosine of an object (using radians). - Parameters
- args (Variable, Input, Calculation) – 1 objects for hyperbolic cosine operation ( cosh(arg0) ) 
 - >>> Calculation('result', COSH(PI / 6)) Calculation report will show --> result = cosh(pi / 6) = cosh(3.142 / 6) = 1.14 
- DIV(*args)
- Used for dviding 2 objects in a calculation. Uses LaTeX formatting \frac{…}{…} - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 objects for division (arg0 / arg1) 
 - >>> v = Variable('v', 2, 'in') >>> c = Calculation('result', DIV(v, v)) Calculation report will show --> result = v / v = 2 in / 2in = 1 
- DIV2(*args)
- Used for dviding 2 objects in a calculation. Uses LaTeX formatting in LaTeX marked by …/… - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 objects for division (arg0 / arg1) 
 - >>> v = Variable('v', 2, 'in') >>> c = Calculation('result', DIV2(v, v)) Calculation report will show --> result = v / v = 2 in / 2in = 1 
- EXP(*args)
- Used to get the exponent (base of e) value of an object. - Parameters
- args (Variable, Input, Calculation) – 1 objects for exp ( exp(arg)=e^arg ) 
 - >>> v = Variable('v', 2) >>> Calculation('result', EXP(v)) Calculation report will show --> result = e^v = e^2 = 7.389 
- LN(*args)
- Used to calculate the natural logarithm of an object. - Parameters
- args (Variable, Input, Calculation) – 1 objects for natural logarithm ( ln(arg) ) 
 - >>> v = Variable('v', 7.389) >>> Calculation('result', LN(v)) Calculation report will show --> result = ln(v) = ln(7.389) = 2 
- LOG10(*args)
- Used to calculate the logarithm of an object for a base of 10. - Parameters
- args (Variable, Input, Calculation) – 1 object for a 10 based logarithm ( ln(arg) ) 
 - >>> v = Variable('v', 10000) >>> Calculation('result', LOG10(v)) Calculation report will show --> result = log_10(v) = log_10(10000) = 4 
- MAX(*args)
- Used to get the maximum value of 2 or more objects. - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 or more objects for maximum ( max(arg0, arg1, …, argLast) ) 
 - >>> v1 = Variable('v1', -2) >>> v2 = Variable('v2', 5) >>> c = Calculation('result', MAX(v1, v2, 1)) Calculation report will show --> result = max(v1, v2, 1) = max(-2, 5, 1) = 5 
- MIN(*args)
- Used to get the minimum value of 2 or more objects. - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 or more objects for minimum ( min(arg0, arg1, …, argLast) ) 
 - >>> v1 = Variable('v1', -2) >>> v2 = Variable('v2', 5) >>> c = Calculation('result', MIN(v1, v2, 1)) Calculation report will show --> result = min(v1, v2, 1) = min(-2, 5, 1) = -2 
- MUL(*args)
- Used for multiplying 2 or more objects in a calculation. - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 or more objects for multiplication ( arg0 * arg1 * … * argLast ) 
 - >>> v = Variable('v', 2, 'in') >>> c = Calculation('result', MUL(v, v, v), 'in^3') Calculation report will show --> result = v * v * v = 2 in * 2 in * 2 in = 8 in^3 
- NEG(*args)
- Used to reverse the sign of (negate) an object. - Parameters
- args (Variable, Input, Calculation) – 1 object for negation ( -arg0) 
 - >>> v = Variable('v', 2, 'in') >>> c = Calculation('result', NEG(v), 'in') Calculation report will show --> result = (- v) = (- 2 in) = -2in 
- POW(*args)
- Used to get the exponential power of 2 objects. - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 objects for power ( arg0 ^ arg1 ) 
 - >>> v1 = Variable('v1', 2) >>> v2 = Variable('v2', 5) >>> c = Calculation('result', POW(v2, v1)) Calculation report will show --> result = v2^v1 = 5^2 = 25 
- RBRACKETS(*args)
- Wraps any calculation expression or variable in round brackets (parantheses) in the calculation report. - Parameters
- args (Variable, Input, Calculation) – 1 objects for round brackets ( (arg) ) 
 - >>> v = Variable('v', 2) >>> Calculation('result', RBRACKETS(v + 1)) Calculation report will show --> result = (v + 1) = (2 + 1) = 3 
- ROOT(*args)
- Used to get the root of an object. - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 objects for root value ( arg1^(1/arg0) ) 
 - >>> v1 = Variable('v1', 3) >>> v2 = Variable('v2', 8) >>> c = Calculation('result', ROOT(v1, v2)) Calculation report will show --> result = v2^(1/v1) = 8^(1/3) = 2 
- SBRACKETS(*args)
- Wraps any calculation expression or variable in square brackets in the calculation report. - Parameters
- args (Variable, Input, Calculation) – 1 objects for square brackets ( [arg] ) 
 - >>> v = Variable('v', 2) >>> Calculation('result', SBRACKETS(v + 1)) Calculation report will show --> result = [v + 1] = [2 + 1] = 3 
- SIN(*args)
- Used to get the trigonometric sine of an object (using radians). - Parameters
- args (Variable, Input, Calculation) – 1 objects for sine operation ( sin(arg0) ) 
 - >>> c = Calculation('result', SIN(PI / 6)) Calculation report will show --> result = sin(pi / 6) = sin(3.142 / 6) = 0.5 
- SINH(*args)
- Used to get the hyperbolic sine of an object (using radians). - Parameters
- args (Variable, Input, Calculation) – 1 objects for hyperbolicsine operation ( sinh(arg0) ) 
 - >>> Calculation('result', SINH(PI / 6)) Calculation report will show --> result = sinh(pi / 6) = sinh(3.142 / 6) = 0.5479 
- SQRT(*args)
- Used to get the square root of an object. - Parameters
- args (Variable, Input, Calculation) – 1 objects for square root ( sqrt(arg) ) 
 - >>> v = Variable('v', 16) >>> c = Calculation('result', SQRT(v)) Calculation report will show --> result = sqrt(v) = sqrt(16) = 4 
- SUB(*args)
- Used for subtracting 2 objects in a calculation. - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 objects for subtraction (arg0 - arg1) 
 - >>> v = Variable('v', 2, 'in') >>> c = Calculation('result', SUB(v, v), 'in') Calculation report will show --> result = v - v = 2 in - 2in = 0 in 
- SUM(*args)
- Used for summing 2 or more objects in a calculation. - Parameters
- args (Variable(s), Input(s), Calculation(s)) – 2 or more objects for summation ( arg0 + arg1 + … + argLast) 
 - >>> v = Variable('v', 2, 'in') >>> c = Calculation('result', SUM(v, v, v), 'in') Calculation report will show --> result = v + v + v = 2 in + 2 in + 2in = 6 in 
- TAN(*args)
- Used to get the trigonometric tangent of an object (using radians). - Parameters
- args (Variable, Input, Calculation) – 1 object for tangent operation ( tan(arg0) ) 
 - >>> c = Calculation('result', TAN(PI / 4)) Calculation report will show --> result = tan(pi / 4) = tan(3.142 / 4) = 1 
- TANH(*args)
- Used to get the hyperbolic tangent of an object (using radians). - Parameters
- args (Variable, Input, Calculation) – 1 object for hyperbolic tangent operation ( tanh(arg0) ) 
 - >>> c = Calculation('result', TANH(PI / 6)) Calculation report will show --> result = tanh(pi / 6) = tanh(3.142 / 6) = 0.4805 
- class Variable(name, value=None, unit='')
- Class representing mathematical or physical variable with units. It is similar to an - Input, but a Variable cannot be changed by a calculation and will only show up on the calculation report when used in a- Calculation,- Comparison, etc.- Parameters
- name (str) – symbolic name of the variable 
- value (float | int) – value of the variable 
- unit (str) – physical unit of the variable 
 
 - >>> v = Variable('var', 2, 'in') >>> c = Calculation('result', v + v, 'in') Calculation report will show --> result = var + var = 2 in + 2 in = 4 in