Perl: Complex Numbers

By Xah Lee. Date:

Perl doesn't support complex numbers. But there are packages for it. One of them is “Math::Complex”.

Here's a excerpt from its documentation:

SYNOPSIS
            use Math::Complex;

            $z = Math::Complex->make(5, 6);
            $t = 4 - 3*i + $z;
            $j = cplxe(1, 2*pi/3);

DESCRIPTION
    This package lets you create and manipulate complex numbers. By default,
    *Perl* limits itself to real numbers, but an extra "use" statement
    brings full complex support, along with a full set of mathematical
    functions typically associated with and/or extended to complex numbers.

    If you wonder what complex numbers are, they were invented to be able to
    solve the following equation:

            x*x = -1

    …

From this, we observe the general Perl programer's understanding of mathematics, and also this package's author's understanding of it. And, as well as the fanaticality and maturity from the writing style.

perldoc Math::Complex

If you have a question, put $5 at patreon and message me.

Perl

  1. Perl Overview
  2. Version String
  3. Help System

Detail

  1. Quoting String
  2. Format String
  3. String Operations
  4. True, False
  5. if then else
  6. Loop
  7. List / Array
  8. Loop Thru List
  9. Map f to List
  10. List Comprehension
  11. Hash Table
  12. Function Optional Param
  13. regex
  14. Split Line by Regex

Advanced

  1. Sort List, Matrix, Object
  2. Sort Matrix
  3. List Modules, Search Paths
  4. Write a Module
  5. Read / Write File
  6. Traverse Dir
  7. Find / Replace
  8. Complex Numbers
  9. System Call
  10. Compress / Decompress gzip
  11. Get Env Var
  12. GET Web Content
  13. Unicode 🐪
  14. Convert File Encoding
  15. Sort Unstable