Litipk\BigNumbers\Decimal::cos PHP Method

cos() public method

Calculates the cosine of this method with the highest possible accuracy Note that accuracy is limited by the accuracy of predefined PI;
public cos ( integer $scale = null ) : Decimal
$scale integer
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);
    }