Skip to content

math.complex.plus

ebp012 edited this page Oct 26, 2024 · 1 revision

The math.complex.plus(a1, b1, a2, b2, datatype, simplify) routine is used to add complex numbers in the form a + bi.

Parameters

It takes on 5 parameters: a1 represents the a value of the first addend, b1 represents the b value of the first addend, a2 represents the a value of the second addend and b2 represents the b value of the second addend.

The datatype parameter specifies the type of data that should be outputted:

If this parameter is omitted entirely or null, then it returns the result of the operation in vector form as an array [d, a3, b3], where d represents the dimensionality (which would be 1 for real numbers, 2 for complex numbers, 4 for quaternions, and so on) and a3 and b3 are the a and b values.

If this parameter has the value "string", a string will be produced as the output containing the entire complex number in standard form.

Only if the datatype parameter is "string" the boolean simplify parameter can be provided. If false, the complex number in the string will not be simplified, leaving in such artifacts as "+-" and "+0i". If omitted, null or true, the number will be simplified completely.

Example

In order to add the complex numbers 3 + 2i with 5 - 6.1i, we can use this code:

print(math.complex.plus(3, 2, 5, -6.1, "string", true));

in order to obtain the result shown below.

8-4.1i

Clone this wiki locally