complex () / () (a bit broken)
Complex () / () (a bit broken)
The complex () / () block is a reporter block in the Extra Mathematics extension that reports the division of the entered complex numbers (which use real and imaginary JSON pairs).
Workaround
This block can be worked around by using the division of the numbers using the conjugate of the 2nd complex number.
define complex (num1) / (num2) set [conjugate] to (join [{"real":] (get [real] from (num2)::extension) [,"imaginary":] ((-1) * (get [imaginary] from (num2)::extension))::operators):: #0869c2 set [top] to (complex (get [conjugate]::#0869c2) * (num1)::#7ac94f)::#0869c2 set [bottom] to (get [real] from (complex (num2) * (get [conjugate]::#0869c2)::#7ac94f)::extension)::#0869c2 set [real part] to ((get [real] from (get [top]::#0869c2)::extension) / (get [bottom]::#0869c2))::#0869c2 set [im part] to ((get [im] from (get [top]::#0869c2)::extension) / (get [bottom]::#0869c2))::#0869c2 return (join [{"real":] (get [real part]:: #0869c2) [,"imaginary":] (get [im part]:: #0869c2) [}]::operators)::custom cap
The variables and code can also be combined to use less lines, though the code having this is in the scratchblocks so it can be read.
The complex () / () custom reporter would then be used in place of the actual block.