@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | ->multiply($e->pow($eExponent)) |
| 33 | 33 | ->multiply(SeriesProvider::maclaurinSeries( |
| 34 | 34 | $x, |
| 35 | - function ($n) { |
|
| 35 | + function($n) { |
|
| 36 | 36 | return Numbers::makeOne(); |
| 37 | 37 | }, |
| 38 | - function ($n) { |
|
| 38 | + function($n) { |
|
| 39 | 39 | return SequenceProvider::nthOddNumber($n); |
| 40 | 40 | }, |
| 41 | - function ($n) { |
|
| 41 | + function($n) { |
|
| 42 | 42 | return SequenceProvider::nthOddNumber($n)->doubleFactorial(); |
| 43 | 43 | } |
| 44 | 44 | )) |
@@ -68,15 +68,15 @@ discard block |
||
| 68 | 68 | $answer = $answer->multiply( |
| 69 | 69 | SeriesProvider::maclaurinSeries( |
| 70 | 70 | $x, |
| 71 | - function ($n) { |
|
| 71 | + function($n) { |
|
| 72 | 72 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1); |
| 73 | 73 | |
| 74 | 74 | return $negOne->pow($n); |
| 75 | 75 | }, |
| 76 | - function ($n) { |
|
| 76 | + function($n) { |
|
| 77 | 77 | return SequenceProvider::nthOddNumber($n); |
| 78 | 78 | }, |
| 79 | - function ($n) { |
|
| 79 | + function($n) { |
|
| 80 | 80 | $n = Numbers::makeOrDont(Numbers::IMMUTABLE, $n); |
| 81 | 81 | |
| 82 | 82 | return $n->factorial()->multiply(SequenceProvider::nthOddNumber($n)); |
@@ -11,57 +11,57 @@ |
||
| 11 | 11 | { |
| 12 | 12 | |
| 13 | 13 | const EULER_ZIGZAG = [ |
| 14 | - '1', // 0 |
|
| 15 | - '1', // 1 |
|
| 16 | - '1', // 2 |
|
| 17 | - '2', // 3 |
|
| 18 | - '5', // 4 |
|
| 19 | - '16', // 5 |
|
| 20 | - '61', // 6 |
|
| 21 | - '272', // 7 |
|
| 22 | - '1385', // 8 |
|
| 23 | - '7936', // 9 |
|
| 24 | - '50521', // 10 |
|
| 25 | - '353792', // 11 |
|
| 26 | - '2702765', // 12 |
|
| 27 | - '22368256', // 13 |
|
| 28 | - '199360981', // 14 |
|
| 29 | - '1903757312', // 15 |
|
| 30 | - '19391512145', // 16 |
|
| 31 | - '209865342976', // 17 |
|
| 32 | - '2404879675441', // 18 |
|
| 33 | - '29088885112832', // 19 |
|
| 34 | - '370371188237525', // 20 |
|
| 35 | - '4951498053124096', // 21 |
|
| 36 | - '69348874393137901', // 22 |
|
| 37 | - '1015423886506852352', // 23 |
|
| 38 | - '15514534163557086905', // 24 |
|
| 39 | - '246921480190207983616', // 25 |
|
| 40 | - '4087072509293123892361', // 26 |
|
| 41 | - '70251601603943959887872', // 27 |
|
| 42 | - '1252259641403629865468285', // 28 |
|
| 43 | - '23119184187809597841473536', // 29 |
|
| 44 | - '441543893249023104553682821', // 30 |
|
| 45 | - '8713962757125169296170811392', // 31 |
|
| 46 | - '177519391579539289436664789665', // 32 |
|
| 47 | - '3729407703720529571097509625856', // 33 |
|
| 48 | - '80723299235887898062168247453281', // 34 |
|
| 49 | - '1798651693450888780071750349094912', // 35 |
|
| 50 | - '41222060339517702122347079671259045', // 36 |
|
| 51 | - '970982810785059112379399707952152576', // 37 |
|
| 52 | - '23489580527043108252017828576198947741', // 38 |
|
| 53 | - '583203324917310043943191641625494290432', // 39 |
|
| 54 | - '14851150718114980017877156781405826684425', // 40 |
|
| 55 | - '387635983772083031828014624002175135645696', // 41 |
|
| 56 | - '10364622733519612119397957304745185976310201', // 42 |
|
| 57 | - '283727921907431909304183316295787837183229952', // 43 |
|
| 58 | - '7947579422597592703608040510088070619519273805', // 44 |
|
| 59 | - '227681379129930886488600284336316164603920777216', // 45 |
|
| 60 | - '6667537516685544977435028474773748197524107684661', // 46 |
|
| 61 | - '199500252157859031027160499643195658166340757225472', // 47 |
|
| 62 | - '6096278645568542158691685742876843153976539044435185', // 48 |
|
| 63 | - '190169564657928428175235445073924928592047775873499136', // 49 |
|
| 64 | - '6053285248188621896314383785111649088103498225146815121', // 50 |
|
| 14 | + '1', // 0 |
|
| 15 | + '1', // 1 |
|
| 16 | + '1', // 2 |
|
| 17 | + '2', // 3 |
|
| 18 | + '5', // 4 |
|
| 19 | + '16', // 5 |
|
| 20 | + '61', // 6 |
|
| 21 | + '272', // 7 |
|
| 22 | + '1385', // 8 |
|
| 23 | + '7936', // 9 |
|
| 24 | + '50521', // 10 |
|
| 25 | + '353792', // 11 |
|
| 26 | + '2702765', // 12 |
|
| 27 | + '22368256', // 13 |
|
| 28 | + '199360981', // 14 |
|
| 29 | + '1903757312', // 15 |
|
| 30 | + '19391512145', // 16 |
|
| 31 | + '209865342976', // 17 |
|
| 32 | + '2404879675441', // 18 |
|
| 33 | + '29088885112832', // 19 |
|
| 34 | + '370371188237525', // 20 |
|
| 35 | + '4951498053124096', // 21 |
|
| 36 | + '69348874393137901', // 22 |
|
| 37 | + '1015423886506852352', // 23 |
|
| 38 | + '15514534163557086905', // 24 |
|
| 39 | + '246921480190207983616', // 25 |
|
| 40 | + '4087072509293123892361', // 26 |
|
| 41 | + '70251601603943959887872', // 27 |
|
| 42 | + '1252259641403629865468285', // 28 |
|
| 43 | + '23119184187809597841473536', // 29 |
|
| 44 | + '441543893249023104553682821', // 30 |
|
| 45 | + '8713962757125169296170811392', // 31 |
|
| 46 | + '177519391579539289436664789665', // 32 |
|
| 47 | + '3729407703720529571097509625856', // 33 |
|
| 48 | + '80723299235887898062168247453281', // 34 |
|
| 49 | + '1798651693450888780071750349094912', // 35 |
|
| 50 | + '41222060339517702122347079671259045', // 36 |
|
| 51 | + '970982810785059112379399707952152576', // 37 |
|
| 52 | + '23489580527043108252017828576198947741', // 38 |
|
| 53 | + '583203324917310043943191641625494290432', // 39 |
|
| 54 | + '14851150718114980017877156781405826684425', // 40 |
|
| 55 | + '387635983772083031828014624002175135645696', // 41 |
|
| 56 | + '10364622733519612119397957304745185976310201', // 42 |
|
| 57 | + '283727921907431909304183316295787837183229952', // 43 |
|
| 58 | + '7947579422597592703608040510088070619519273805', // 44 |
|
| 59 | + '227681379129930886488600284336316164603920777216', // 45 |
|
| 60 | + '6667537516685544977435028474773748197524107684661', // 46 |
|
| 61 | + '199500252157859031027160499643195658166340757225472', // 47 |
|
| 62 | + '6096278645568542158691685742876843153976539044435185', // 48 |
|
| 63 | + '190169564657928428175235445073924928592047775873499136', // 49 |
|
| 64 | + '6053285248188621896314383785111649088103498225146815121', // 50 |
|
| 65 | 65 | ]; |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ($terms > 2) { |
| 33 | - for ($n = 2;$n < $terms;$n++) { |
|
| 33 | + for ($n = 2; $n < $terms; $n++) { |
|
| 34 | 34 | $kN = $k1->add($k2); |
| 35 | 35 | $collection->push($kN); |
| 36 | 36 | |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | return $sample; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableNumber; |
|
| 28 | + abstract public function rangeRandom($min = 0, $max = PHP_INT_MAX, int $maxIterations = 20): ImmutableNumber; |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $sample = new NumberCollection(); |
| 20 | 20 | |
| 21 | - for ($i = 1;$i < $sampleSize;$i++) { |
|
| 21 | + for ($i = 1; $i < $sampleSize; $i++) { |
|
| 22 | 22 | $sample->push($this->random()); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $curVal = $this->getValue(); |
| 34 | 34 | $calcVal = Numbers::make(Numbers::IMMUTABLE, 1); |
| 35 | 35 | |
| 36 | - for ($i = 1;$i <= $curVal;$i++) { |
|
| 36 | + for ($i = 1; $i <= $curVal; $i++) { |
|
| 37 | 37 | $calcVal = $calcVal->multiply($i); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $answer = SeriesProvider::maclaurinSeries( |
| 31 | 31 | $modulo, |
| 32 | - function ($n) { |
|
| 32 | + function($n) { |
|
| 33 | 33 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1, 100); |
| 34 | 34 | |
| 35 | 35 | return $negOne->pow($n); |
| 36 | 36 | }, |
| 37 | - function ($n) { |
|
| 37 | + function($n) { |
|
| 38 | 38 | return SequenceProvider::nthOddNumber($n); |
| 39 | 39 | }, |
| 40 | - function ($n) { |
|
| 40 | + function($n) { |
|
| 41 | 41 | return SequenceProvider::nthOddNumber($n)->factorial(); |
| 42 | 42 | }, |
| 43 | 43 | 0, |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $answer = SeriesProvider::maclaurinSeries( |
| 73 | 73 | $modulo, |
| 74 | - function ($n) { |
|
| 74 | + function($n) { |
|
| 75 | 75 | return SequenceProvider::nthPowerNegativeOne($n); |
| 76 | 76 | }, |
| 77 | - function ($n) { |
|
| 77 | + function($n) { |
|
| 78 | 78 | return SequenceProvider::nthEvenNumber($n); |
| 79 | 79 | }, |
| 80 | - function ($n) { |
|
| 80 | + function($n) { |
|
| 81 | 81 | return SequenceProvider::nthEvenNumber($n)->factorial(); |
| 82 | 82 | }, |
| 83 | 83 | 0, |
@@ -162,20 +162,20 @@ discard block |
||
| 162 | 162 | } else { |
| 163 | 163 | $answer = SeriesProvider::maclaurinSeries( |
| 164 | 164 | $modulo, |
| 165 | - function ($n) { |
|
| 165 | + function($n) { |
|
| 166 | 166 | $nthOddNumber = SequenceProvider::nthOddNumber($n); |
| 167 | 167 | |
| 168 | 168 | return SequenceProvider::nthEulerZigzag($nthOddNumber); |
| 169 | 169 | }, |
| 170 | - function ($n) { |
|
| 170 | + function($n) { |
|
| 171 | 171 | |
| 172 | 172 | return SequenceProvider::nthOddNumber($n); |
| 173 | 173 | }, |
| 174 | - function ($n) { |
|
| 174 | + function($n) { |
|
| 175 | 175 | return SequenceProvider::nthOddNumber($n)->factorial(); |
| 176 | 176 | }, |
| 177 | 177 | 0, |
| 178 | - $precision + 1 |
|
| 178 | + $precision+1 |
|
| 179 | 179 | ); |
| 180 | 180 | } |
| 181 | 181 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | if ($mod2Pi->isEqual(0)) { |
| 216 | 216 | return $this->setValue(static::INFINITY); |
| 217 | - } elseif($modPi->isEqual(0)) { |
|
| 217 | + } elseif ($modPi->isEqual(0)) { |
|
| 218 | 218 | return $this->setValue(static::NEG_INFINITY); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | |
| 43 | 43 | $rounded = $whole.'.'; |
| 44 | 44 | |
| 45 | - for ($i = 0;$i < $decimals;$i++) { |
|
| 45 | + for ($i = 0; $i < $decimals; $i++) { |
|
| 46 | 46 | $rounded .= $fractionalArr[$i]; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | } elseif ($this->isEqual(0)) { |
| 29 | 29 | $answer = Numbers::makeZero(); |
| 30 | 30 | } else { |
| 31 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
| 31 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
| 32 | 32 | $one = Numbers::makeOne($precision+2); |
| 33 | 33 | |
| 34 | 34 | if ($z->abs()->isGreaterThan(1)) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $answer = $z->divide($one->subtract($z->pow(2))->sqrt($precision + 2), $precision + 2)->arctan($precision + 2, false); |
|
| 42 | + $answer = $z->divide($one->subtract($z->pow(2))->sqrt($precision+2), $precision+2)->arctan($precision+2, false); |
|
| 43 | 43 | } |
| 44 | 44 | if ($round) { |
| 45 | 45 | $answer = $answer->roundToPrecision($precision); |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | } elseif ($this->isEqual(1)) { |
| 67 | 67 | $answer = Numbers::makeZero(); |
| 68 | 68 | } else { |
| 69 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
| 70 | - $one = Numbers::makeOne($precision + 2); |
|
| 69 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
| 70 | + $one = Numbers::makeOne($precision+2); |
|
| 71 | 71 | |
| 72 | 72 | if ($z->abs()->isGreaterThan(1)) { |
| 73 | 73 | throw new IntegrityConstraint( |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $answer = $one->subtract($z->pow(2)) |
| 81 | - ->sqrt($precision + 2) |
|
| 82 | - ->divide($z, $precision + 2) |
|
| 83 | - ->arctan($precision + 2, false); |
|
| 81 | + ->sqrt($precision+2) |
|
| 82 | + ->divide($z, $precision+2) |
|
| 83 | + ->arctan($precision+2, false); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | if ($round) { |
@@ -98,41 +98,41 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $precision = $precision ?? $this->getPrecision(); |
| 100 | 100 | |
| 101 | - $one = Numbers::makeOne($precision + 2); |
|
| 101 | + $one = Numbers::makeOne($precision+2); |
|
| 102 | 102 | |
| 103 | 103 | $oldBase = $this->convertForModification(); |
| 104 | 104 | |
| 105 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
| 105 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
| 106 | 106 | |
| 107 | 107 | if ($z->isEqual(1)) { |
| 108 | - $answer = Numbers::makePi($precision + 2)->divide(4, $precision + 2); |
|
| 108 | + $answer = Numbers::makePi($precision+2)->divide(4, $precision+2); |
|
| 109 | 109 | } elseif ($z->isEqual(-1)) { |
| 110 | - $answer = Numbers::makePi($precision + 2)->divide(4, $precision +2)->multiply(-1); |
|
| 110 | + $answer = Numbers::makePi($precision+2)->divide(4, $precision+2)->multiply(-1); |
|
| 111 | 111 | } else { |
| 112 | 112 | |
| 113 | 113 | if ($z->abs()->isGreaterThan(1)) { |
| 114 | - $rangeAdjust = Numbers::makePi($precision + 2)->divide(2, $precision + 2); |
|
| 114 | + $rangeAdjust = Numbers::makePi($precision+2)->divide(2, $precision+2); |
|
| 115 | 115 | |
| 116 | 116 | if ($z->isNegative()) { |
| 117 | 117 | $rangeAdjust = $rangeAdjust->multiply(-1); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $z = $one->divide($z, $precision + 2); |
|
| 120 | + $z = $one->divide($z, $precision+2); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $answer = SeriesProvider::maclaurinSeries( |
| 124 | 124 | $z, |
| 125 | - function ($n) { |
|
| 125 | + function($n) { |
|
| 126 | 126 | return SequenceProvider::nthPowerNegativeOne($n); |
| 127 | 127 | }, |
| 128 | - function ($n) { |
|
| 128 | + function($n) { |
|
| 129 | 129 | return SequenceProvider::nthOddNumber($n); |
| 130 | 130 | }, |
| 131 | - function ($n) { |
|
| 131 | + function($n) { |
|
| 132 | 132 | return SequenceProvider::nthOddNumber($n); |
| 133 | 133 | }, |
| 134 | 134 | 0, |
| 135 | - $precision + 1 |
|
| 135 | + $precision+1 |
|
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | 138 | if (isset($rangeAdjust)) { |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $precision = $precision ?? $this->getPrecision(); |
| 157 | 157 | |
| 158 | - $piDivTwo = Numbers::makePi($precision + 2)->divide(2, $precision + 2); |
|
| 158 | + $piDivTwo = Numbers::makePi($precision+2)->divide(2, $precision+2); |
|
| 159 | 159 | |
| 160 | 160 | $oldBase = $this->convertForModification(); |
| 161 | 161 | |
| 162 | - $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision + 2); |
|
| 162 | + $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
|
| 163 | 163 | |
| 164 | 164 | $arctan = $z->arctan($precision+2, false); |
| 165 | 165 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $oldBase = $this->convertForModification(); |
| 184 | 184 | |
| 185 | - $one = Numbers::makeOne($precision + 2); |
|
| 185 | + $one = Numbers::makeOne($precision+2); |
|
| 186 | 186 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
| 187 | 187 | |
| 188 | 188 | if ($z->abs()->isLessThan(1)) { |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | ); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $answer = $one->divide($z, $precision + 2)->arccos($precision + 2); |
|
| 196 | + $answer = $one->divide($z, $precision+2)->arccos($precision+2); |
|
| 197 | 197 | |
| 198 | 198 | if ($round) { |
| 199 | 199 | $answer = $answer->roundToPrecision($precision); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $oldBase = $this->convertForModification(); |
| 214 | 214 | |
| 215 | - $one = Numbers::makeOne($precision + 2); |
|
| 215 | + $one = Numbers::makeOne($precision+2); |
|
| 216 | 216 | $z = Numbers::makeOrDont(Numbers::IMMUTABLE, $this, $precision+2); |
| 217 | 217 | |
| 218 | 218 | if ($z->abs()->isLessThan(1)) { |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - $answer = $one->divide($z, $precision + 2)->arcsin($precision + 2); |
|
| 226 | + $answer = $one->divide($z, $precision+2)->arcsin($precision+2); |
|
| 227 | 227 | |
| 228 | 228 | if ($round) { |
| 229 | 229 | $answer = $answer->roundToPrecision($precision); |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | public function __construct($value, $precision = null, $base = 10) |
| 51 | 51 | {
|
| 52 | 52 | $this->base = $base; |
| 53 | - $this->value = (string)$value; |
|
| 53 | + $this->value = (string) $value; |
|
| 54 | 54 | $this->setMode(Number::MODE_PRECISION); |
| 55 | 55 | |
| 56 | 56 | if (!is_null($precision)) {
|