PHP code example of markbaker / complex
1. Go to this page and download the library: Download markbaker/complex library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
markbaker / complex example snippets
$real = 1.23;
$imaginary = -4.56;
$suffix = 'i';
$complexObject = new Complex\Complex($real, $imaginary, $suffix);
$real = 1.23;
$imaginary = -4.56;
$suffix = 'i';
$arguments = [$real, $imaginary, $suffix];
$complexObject = new Complex\Complex($arguments);
$complexString = '1.23-4.56i';
$complexObject = new Complex\Complex($complexString);
$complexString1 = '1.23-4.56i';
$complexString2 = '2.34+5.67i';
$complexObject = new Complex\Complex($complexString1);
echo $complexObject->add($complexString2);
$complexString1 = '1.23-4.56i';
$complexString2 = '2.34+5.67i';
echo Complex\Operations::add($complexString1, $complexString2);
$complexString = '1.23-4.56i';
$complexObject = new Complex\Complex($complexString);
echo $complexObject->sinh();
$complexString = '1.23-4.56i';
echo Complex\Functions::sinh($complexString);
$complexString = '1.23-4.56i';
$complexObject = new Complex\Complex($complexString);
echo Complex\Functions::pow($complexObject, 2);
$complexString = '1.23-4.56i';
$complexObject = new Complex\Complex($complexString);
echo $complexObject->pow(2);