Litipk\BigNumbers\Decimal::arcsec PHP Méthode

arcsec() public méthode

Calculates the arcsecant of this with the highest possible accuracy
public arcsec ( integer $scale = null ) : Decimal
$scale integer
Résultat Decimal
    public function arcsec($scale = null)
    {
        if ($this->comp(DecimalConstants::one(), $scale + 2) === -1 && $this->comp(DecimalConstants::negativeOne(), $scale + 2) === 1) {
            throw new \DomainException("The arcsecant of this number is undefined.");
        }
        $piOverTwo = DecimalConstants::pi()->div(Decimal::fromInteger(2), $scale + 2)->round($scale);
        if ($this->round($scale)->equals(DecimalConstants::one())) {
            return DecimalConstants::zero();
        }
        if ($this->round($scale)->equals(DecimalConstants::negativeOne())) {
            return DecimalConstants::pi()->round($scale);
        }
        $scale = $scale === null ? 32 : $scale;
        return $piOverTwo->sub(self::powerSerie(DecimalConstants::one()->div($this, $scale + 2), DecimalConstants::zero(), $scale + 2))->round($scale);
    }