PHP Classes

File: complextest.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Mo´se  >  PHP Complex Numbers class  >  complextest.php  >  Download  
File: complextest.php
Role: Example script
Content type: text/plain
Description: test
Class: PHP Complex Numbers class
Perform arithmetic operations with complex numbers
Author: By
Last change:
Date: 4 years ago
Size: 2,077 bytes
 

Contents

Class file image Download
<?php
require_once('ArComplex.class.php');

echo
'<pre>';
echo
'<h3>exponential form: </h3>';
var_dump($a=new Arcomplex('5.6111611111-3.59I'));
var_dump($exp=$a->Cexponentialform());
var_dump(exptocomplex($exp));
var_dump(exptocomplex("6.6613233681245*(e(-0.56916865378565*i))"));
var_dump(exptocomplex("6.6613233681245(e(-0.56916865378565i))"));
var_dump(exptocomplex("6.6613233681245.(e(-0.56916865378565.i))"));
echo
'<h3>Complex power: </h3>';
$c=new Arcomplex('0.001+0.6533I');
var_dump($c->Cpow(-2));
var_dump($c->Cpow(2));
$x=new COP(new Arcomplex($c->Cpow(-10)),new Arcomplex($c->Cpow(10)));
var_dump($x->Cmul());
$x=new COP(new Arcomplex('1+3I'),new Arcomplex('1-3I'));
echo
'<h3>Complex division and multiplication: </h3>';
var_dump($x->Cdiv());
var_dump($x->Cmul());
$x=new COP(new Arcomplex('1-1.5i'),new Arcomplex('1-i'));
var_dump($x->Cdiv());
var_dump($x->Cmul());
echo
'<h3>Complex inverse and opposite form: </h3>';
var_dump($a=new Arcomplex('-2+2I'));
var_dump($e=$a->Cinv());
var_dump($e->Cform());
var_dump($e=$a->Copp());
var_dump($e->Cform());
echo
'<h3>Complex square root: </h3>';
var_dump($a=new Arcomplex('-4'));
var_dump($e=$a->Csqrt());
var_dump($e->Cform());
$x=new COP(new Arcomplex($e->Cform()),new Arcomplex($e->Cform()));
var_dump($x->Cmul());
var_dump($a=new Arcomplex(array(-4,6)));
var_dump($e=$a->Csqrt());
var_dump($e->Cform());
$x=new COP(new Arcomplex($e->Cform()),new Arcomplex($e->Cform()));
var_dump($x->Cmul());
var_dump($a=new Arcomplex(array('Im'=>-4,'Re'=>6)));
var_dump($e=$a->Csqrt());
var_dump($e->Cform());
$x=new COP(new Arcomplex($e->Cform()),new Arcomplex($e->Cform()));
var_dump($x->Cmul());
echo
'<h3>Complex all square roots: </h3>';
var_dump($a=new Arcomplex(array(0,-0.001)));
var_dump($e=$a->AllCsqrt());
var_dump($e[0]->Cform());
var_dump($e[1]->Cform());
$x=new COP(new Arcomplex($e[0]->Cform()),new Arcomplex($e[0]->Cform()));
var_dump($x->Cmul());
$x=new COP(new Arcomplex($e[1]->Cform()),new Arcomplex($e[1]->Cform()));
var_dump($x->Cmul());
echo
'<pre>';

For more information send a message to info at phpclasses dot org.