コード例 #1
0
 /**
  * @expectedException \DomainException
  * @expectedExceptionMessage The tangent of this 'angle' is undefined.
  */
 public function testTanPiTwoDiv()
 {
     $PiDividedByTwo = DecimalConstants::PI()->div(Decimal::fromInteger(2));
     $PiDividedByTwo->tan();
 }
コード例 #2
0
 /**
  * Calculates the cosine of this method with the highest possible accuracy
  * Note that accuracy is limited by the accuracy of predefined PI;
  *
  * @param integer $scale
  * @return Decimal cos($this)
  */
 public function cos($scale = null)
 {
     // First normalise the number in the [0, 2PI] domain
     $x = $this->mod(DecimalConstants::PI()->mul(Decimal::fromString("2")));
     // PI has only 32 significant numbers
     $scale = $scale === null ? 32 : $scale;
     return self::factorialSerie($x, DecimalConstants::one(), function ($i) {
         return $i % 2 === 0 ? $i % 4 === 0 ? DecimalConstants::one() : DecimalConstants::negativeOne() : DecimalConstants::zero();
     }, $scale);
 }
コード例 #3
0
 /**
  * @expectedException \DomainException
  * @expectedExceptionMessage The cotangent of this 'angle' is undefined.
  */
 public function testCotanPiDiv()
 {
     $PI = DecimalConstants::PI();
     $PI->cotan();
 }