Custom mathematical formulas
The MATH type lets you define functions that are evaluated as direct mathematical formulas, without using distributions or precomputed value tables. They are useful when the value we need depends on variables deterministically, or on an algebraic expression.
This type of function does not generate randomness. It simply takes the parameters in order, substitutes them into the expression, and returns the result.
Syntax:
Function {Name:name, Type:MATH, Expression:"A + B * C"}
Name: identifier name of the function.Type: must beMATH.Expression: formula to evaluate, using uppercase letters as variables (A, B, C...). These letters represent the parameters passed in order.
How do you call a MATH function?
It is used like any FN$ function, but with parameters in parentheses:
FN$(name, value_A, value_B, ...)
Example
/*
Math
*/
Graphic {NAME:Text1,Type:TEXT,X:370,Y:312,Text:"Hello"}
Function {Name:math1, type: MATH, EXPRESSION:"A * 2 + B"}
START 1
;*****************************************************
GENERATE 1,0,0,1 {NAME:GEN1,X:56,Y:319}
assign AAA,4
assign BBB,6
move {name:Text1,text:"Result: FN$(math1,P$AAA,P$BBB)"}
ENDGENERATE 1