Math::N...aumSweet(3)
π Math::N...aumSweet π
okay bestie, so this whole thing lives in the User Contributed Perl Documentation corner of the perl universe, and the page itself is Math::N...aumSweet(3) β yes the name is squished like that, that's just how it's printed, don't @ me. it's the Baum-Sweet sequence and it's honestly kinda iconic once you get it. let's go π¦
β¨ NAME β¨
Math::NumSeq::BaumSweet β the Baum-Sweet sequence, no cap
π SYNOPSIS π
like, the whole vibe in four lines:
use Math::NumSeq::BaumSweet;
my $seq = Math::NumSeq::BaumSweet->new;
my ($i, $value) = $seq->next;
πΈ DESCRIPTION πΈ
so the Baum-Sweet sequence goes like this:
1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, ...
starting i=0
and here's the tea β β every value is 1 when the index i, written out in binary, has no odd-length run of 0-bits in it. and it's 0 if it does have one. that's it. that's the whole bit. π
if you want the academic receipts, they're right here:
Leonard E. Baum and Melvin M. Sweet, "Continued Fractions of Algebraic Power Series in Characteristic 2", Annals of Mathematics, volume 103, number 3, May 1976, pages 593-610. /www.jstor.org/stable/1970953 in href="http:
fr fr, that's the source. scholars. π
and lowkey the reason this sequence even exists? it's the coefficients of a Laurent series that is the unique solution to:
f(x)^3 + (1/x)*f(x) + 1 = 0
and the authors note that this same thing has the bitwise interpretation we just talked about up there. their actual interest, though? certain continued fraction forms for the series. main character research energy, honestly. π
π FUNCTIONS π
peep "FUNCTIONS" in Math::NumSeq for the behaviour that all the sequence classes share, bc that's the common ground bestie.
$seq = Math::NumSeq::BaumSweet->new ()β makes you a brand new sequence object and hands it over. slay.
π¦ Random Access π¦
$value = $seq->ith($i)β gimme the$i'th BaumSweet number. it's1or0, depending on whether$iis without or with an odd-length run of 0-bits. simple as that.$bool = $seq->pred($value)β returns true if$valueeven shows up in the sequence, which honestly just means it's0or1. that's the whole membership test. periodt.
π SEE ALSO π
go read these next, they're all in the same friend group:
Math::NumSeqMath::NumSeq::GolayRudinShapiroMath::NumSeq::Fibbinary
β HOME PAGE β
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
Copyright 2011, 2012, 2013, 2014, 2016, 2017, 2019, 2020 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
not me being legally obligated to say all that, but yes, the no-warranty part is real and you should actually read it bestie π«Ά
and that's the whole page!! π this cutie is running on perl v5.42.0, dated 2025-07-25, and the page goes by Math::N...aumSweet(3) β mwah, bye, go compute some sequences πβ¨
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms