hp
jblog
toc

A325902

2019-10-05, post № 220

mathematics, #factorization, #integer, #OEIS, #sequence

Fifty is a peculiar integer.
When looking at its neighbors — the largest integer strictly beneath and the smallest strictly above —, more specifically their prime factorization, one finds

49=\underbrace{7^2<50<3\cdot 17}_{7+7+3=17}=51.

Notably, there exists a partition of the neighbor’s factors into two multisets such that both parts’ sums equal another.

Positive integers with the above described property can be found in my most recent addition to the OEIS: sequence A325902.

Digit Sums

2019-09-07, post № 219

mathematics, #base ten, #factoid, #Jack Reacher

Interessant war es auch, drei aufeinanderfolgende Zahlen zu nehmen, von denen die größte durch drei teilbar sein musste, sie zu addieren und aus dem Ergebnis so lange die Quersumme zu bilden, bis eine einstellige Zahl übrig blieb. Diese Zahl war immer sechs.
— Child, Lee: Der Anhalter. München: Blanvalet, 2015; p. 73

Jack Reacher’s at most tangentially to interpreting the sergeant’s reply related base ten factoid’s formal form is

\forall n\in\mathbb{N}^+:\mathrm{fds}_{10}\left(\sum\limits_{j=0}^2 3\,n-j\right)=6,

where \mathrm{fds}_{10} represents the final digit sum in base ten.

A proof of the above claim together with the underlying digit sum results is presented in digit-sums.pdf [1] (source: digit-sums.tex).

Short brainfuck Primes

2019-08-10, post № 218

brainfuck, programming,

>[-]+>>[-]++>[-]<<<[>[-]+>>>>[-]<[-]<<[>>>+<+<<-]>>>[<<<+>>>-]>[-]<[-]<<[>>>+<+<<-]>>>[<<<+>>>-][-]+[>>>>[-]<[-]<<<<<[>>>>>>+<+<<<<<-]>>>>>>[<<<<<<+>>>>>>-]<<[-]+>[<->[-]]<[<<<->>>[-]]<<<<->>>>>[-]<[-]<<<<<<[>>>>>>>+<+<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]>[-]<[-]<<<<<<[>>>>>>>+<+<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-][-]>[-]>[-]>>[-]<[-]<[>>+<+<-]>>[<<+>>-]>[-]<[-]<<[>>>+<+<<-]>>>[<<<+>>>-]>[-]<[-]<<<[>>>>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]]<[-]]<<<<]

Try it online.

Mandelbrot set sketch in Scratch

2019-07-13, post № 217

art, mathematics, programming, #fractal

Despite my personal disbelieve in and dislike of the colored blocks dragging simulator 3, I nevertheless wanted to extract functionality other than the hardcoded cat mascot path tracing from the aforementioned software; one of the most efficient visual result to build effort ratio yields a simple plot of the Mandelbrot set, formally known as

M:=\{z\in\mathbb{C}:|\lim_{n\to\infty}\mathrm{itr}^n(z)|<\infty\}

where the iterator is defined as

\mathrm{itr}^n(z) := \mathrm{itr}^{n-1}(z)^2+z, \\ \mathrm{itr}^0(z) := 0.

The render resolution is kept at a recognizable minimum as not to overburden the machine tasked with creating it.
Source: mandelbrot-set-sketch-in-scratch.sb3

mandelbrot-set-sketch-in-scratch.png

Factoids #0

2019-06-15, post № 216

mathematics, #algebra, #rings

I) Unit polynomials with non-vanishing degree

2t+1\in\mathbb{Z}_4[t] is its own multiplicative inverse, showing that R[t]^*=R^* does not hold in a general commutative Ring with one.

This phenomenon is uniquely characterized by the following equivalence:

R[t]^*=R^*\iff\nexists\,0\neq a,b\in R:a\cdot b=0=a+b
Proof. Negated replication. Let R\not\owns f=\sum_{i=0}^n\alpha_it^i\in R[t]^*,\alpha_n\neq 0 be a unit polynomial of non-vanishing degree n\geq 1. Let g=\sum_{j=0}^m\beta_jt^j\in R[t]^*,\beta_m\neq 0 denote its multiplicative inverse, i. e. f\cdot g=1.
Claim. The polynomial g has non-vanishing degree m\geq 1.
Proof. Suppose g\in R. Since f\cdot g=\sum_{i=0}^n(\alpha_i\cdot g)t^i, it follows from \alpha_n\cdot g=0 that g is a zero divisor. However, at the same time a_0\cdot g=1 implies that g is a unit, arriving at a contradiction.
Since both n,m\geq 1, one concludes \exists 1\leq k\leq m as well as \alpha_n\cdot\beta_m=0.
Existence of the desired ring elements a,b is assured by the following construction.
  • Let k=1\nearrow m rise discretely.
  • If a:=\alpha_n\beta_{m-k}\neq 0, implying b:=\sum_{i=1}^k\alpha_{n-i}\beta_{m-k+i}\neq 0, holds, since the construction arrived at this point, one finds
    a\cdot b=\alpha_n\beta_{m-k}\cdot \sum_{i=1}^k\alpha_{n-i}\beta_{m-k+i}=\sum_{i=1}^k \underbrace{\alpha_n\beta_{m-k+i}}_{=0}\cdot \alpha_{n-i}\beta_{m-k}=0.
  • The above condition is met for at least one 1\leq k\leq m, since otherwise k=m would imply \alpha_n\beta_{m-m}=0, which is impossible since \alpha_n\neq 0 and \beta_0 is a unit element.
By construction, 0\neq a,b as well as a+b=0 are given.
Negated implication. Setting  f:=at+1, g:=bt+1, one calculates
f\cdot g=(at+1)\cdot (bt+1)=abt^2+(a+b)\cdot t+1=0t^2+0t+1=1,
showing R\not\owns f,g\in R[t]^*.

Mostly Misaligned Mirrors

2019-05-18, post № 215

mathematics, PIL, programming, Python, #paths, #random, #simulation, #stochastic

Recently, my stochastic professor introduced me to a problem he has been pondering for over two decades: on the two-dimensional integer lattice \mathbb{Z}^2 one shall flip a three-sided coin for each point and uniformly place one of three mirrors, \{\diagup,\,\cdot\,,\diagdown\}, where \,\cdot\, denotes not placing a mirror. After having populated the world, one picks their favorite integer tuple and points a beam of light in one of the four cardinal directions. With what probability does the light fall into a loop, never fully escaping?

mostly-misaligned-mirrors-5_scaled.png
A cycle which includes the origin.

krrp

2019-04-20, post № 214

C, krrp, programming, #2018

A project of epic proportions has come to a close. Yesterday, the 19th of April 2019, saw the first public release of my new programming language, krrp.

As of the 24th of April 2019, krrp is kindly included in the TIO language collection, making krrp interpretation available from within the web. Great thanks go out to TIO for providing this service.

krrp is a functional, dynamic, interpreted and (theoretically) Turing-complete esolang implemented only using standard C. As such, on top of designing the actual language, any data structures, memory management and general auxiliary functionality deviating from the lacking capabilities offered by C had to be home-brewed and hand-crafted. A time-consuming task — I have been working on this language for the past year. However, it gives the language a certain purity, as its high-level functional approach rests firmly and closely on the state-changing, mutable and segmentation-faulting depths that are the C language.

Sudoku Generation

2019-03-23, post № 213

games, Haskell, programming, #generator, #puzzle

Over two years ago, I wrote a basic 𝟥 ⨉ 𝟥-sudoku solver which uses both fundamental rule-based elimination and guessing to arrive at the solution. Revisiting the topic of computer-aided sudoku manipulation, I wrote a generalized sudoku generator (sudoku-generation.hs).

    | 4  
  3 |    
---------
  2 | 1  
  4 |    

./sudoku 5 2
Jonathan Frech's blog; built 2024/11/02 16:03:59 CET