markbaker/complex
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
MarkBaker/Complex is a versatile PHP library designed to simplify operations with complex numbers, making it an invaluable tool for developers working on mathematical or scientific projects. The package provides various operations such as addition, subtraction, multiplication, and division, along with a range of functions including but not limited to theta, rho, and conjugate. It also offers advanced mathematical functions like cosine, inverse cosine, hyperbolic cosine, and more. The capability to work with advanced mathematical functions is a major growth factor for this PHP library's popularity.
To use the MarkBaker/Complex package, you need to first install it via Composer by running composer require markbaker/complex:^1.0
in the shell. The library exposes an easy-to-use API for handling complex number operations. To create a new complex object, you need to supply the real, imaginary, and suffix parts as individual values, an array, or as a complex number string to the Complex class. For instance,
$real = 1.23;
$imaginary = -4.56;
$suffix = 'i';
$complexObject = new Complex\Complex($real, $imaginary, $suffix);
or as an array
$real = 1.23;
$imaginary = -4.56;
$suffix = 'i';
$arguments = [$real, $imaginary, $suffix];
$complexObject = new Complex\Complex($arguments);
After creating a complex number, you can perform mathematical operations such as addition or multiplication, using methods like add()
or multiply()
.
$complexString1 = '1.23-4.56i';
$complexString2 = '2.34+5.67i';
$complexObject = new Complex\Complex($complexString1);
echo $complexObject->add($complexString2);
Note that complex objects are immutable, meaning that every operation returns a new complex object while the original remains unchanged.
Unfortunately, according to the readme content provided, there doesn't appear to be a dedicated documentation for the MarkBaker/Complex package outside of the readme or source code comments within the library itself. If more detailed documentation is essential for your needs, you may want to explore the source code comments, the GitHub repository's Issues section, or potentially reach out to the developers directly on GitHub.