Showing posts with label PI. Show all posts
Showing posts with label PI. Show all posts

2021-12-26

Irrational numbers and copyright

One of the fun concepts in mathematics is that every (finite) sequence of digits exists somewhere in π.

There are webs sites that explain this (e.g. here) and point out that it has not been proven. It sort of makes some sense, as π is irrational, meaning the digit sequence in infinitely long and never starts to repeat. It seems intuitive that it must therefore contain all finite sequences of digits.

If true, then yes, every possible sequence exists. and the idea is Don't work out π in binary. If you do, you breach copyright (not true, just creating the same thing originally rather than copying it is not a breach of copyright), trademark infringement, and a whole load of other issues.

Of course the same argument applies to creating a near infinite random number :-)

A rational number will always start to repeat - that is pretty easy to prove, and even that the repetition is going to be no longer than the denominator. π, being irrational, does not repeat.

My first reaction to this idea is that just being irrational (and so infinitely long), does not mean it has every finite digit sequence. My argument is simple, take π, and add a 0 between every digit. You still have an infinite sequence, and it still won't start to repeat and so is irrational, but does not even have the sequence 123 in it.

But then it occurred to me - is what I am suggesting a sane thing to do? Someone else pointed out (on twitter) that they do not know of any mathematical function that could insert a 0 every other digit. OK, but does what I am doing have to be a mathematical function?

Today it occurred to me that maybe what I am saying, even though it sounds simple, may not actually be a reasonably thing to suggest. That maybe the number I am creating is not "genuine" in some way, a number that could not be created. So maybe my argument is not sound.

Bear with me - it is not as daft as it sounds to dismiss a number I have created by description as not genuine.

E.g. take the number ⅓, in decimal, and add a 7 to the end of it. Now it is not rational, is it?

That clearly is nonsense. You cannot add a 7 to the end of an infinite sequence of digits (well, not that end anyway). So that concept is easy to dismiss as not "genuine".

But suggesting a 0 is added between each digit of π is equally impossible - I am adding infinite digits. If ever I stop doing so, π goes on as normal and maybe contains every finite sequence of digits.

So is what I suggested not sensible. Could there by a genuine irrational number that does obviously not contain every finite sequences of digits?

2020-03-14

Pi day

As it is Pi day (14th March) I thought I would say something obvious, but slightly mind blowing about another irrational number.

When you square a decimal number, you always end up with twice as many significant digits, or one fewer. e.g. 214² = 45796 (3 digits times 2 is 6, but in this case one less, 5), 56² = 3136 (2 digits times 2 is 4). If you think about it, it is obvious. Basically, for the last digit you multiply out not to count as a significant digit, it would have to be 0. You can do that with 2*5, but not by squaring any final significant digit.

But √2 is irrational. It goes on forever. It starts 1.41421356237 (12 significant digits), which squared is be 1.9999999999912458800169 (23 significant digits, i.e. 12*2-1).

Obviously the more digits, the closer... even lots, such as 1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623091229702492483605585073721264412149709993583141322266592750559275579995050115278206057147010955997160597027453459686201472851741864088919860955232923048430871432145083976260362799525140798968725339654633180882964062061525835239505474575028775996172983557522033753185701135437460340849884716038689997069900481503054402779031645424782306849293691862158057846311159666871301301561856898723723528850926486124949771542183342042856860601468247207714358548741556570696776537202264854470158588016207584749226572260020855844665214583988939443709265918003113882464681570826301005948587040031864803421948972782906410450726368813137398552561173220402450912277002269411275736272804957381089675040183698683684507257993647290607629969413804756548237289971803268024744206292691248590521810044598421505911202494413417285314781058036033710773091828693147101711116839165817268894197587165821521282295184884720896946338628915628827659526351405422676532396946175112916024087155101351504 squared, is 1.9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999843358064061778389918448031979379487768885015043845659822004916377513166730291211571068952082602447585053372271803775212141335211046806468017544012173246168673653215429898752600809076945040478226149804752092795249913294211896685919489781038912339790863836308797672158570101054709837854108990150947671626758096902141232172374611365869462539815599093474631680641002315522198827855254655681178183773171267162025505081207619119154315015019593781997539423459450924437955866358803983089345879502011206070716091422845617882605404958297112110314310433923158845197889301909351312924983769999151087074570462040601631719823168853951704021687236598419124498942731362178121174457523357788222619729955636686231081657732082989686914502778260949270241394967997279088545806588326980598466346571508275959469245048169832037947129583450529101421217940987273080154757322849492641724996747550397932241142493214043106291202086235967891808498928787226259087932847850782010982642427061227177199617553123685346155963957806300620208169830364794225870383219224922644130340677633853727891782934367363062016

Yes, lots of 9's after that 1. but it just gets more complex.

What must blow your mind is that ultimately, to infinite digits, the answer does actually cancel out and actually end up as exactly 2.

How?!?!


2018-01-05

Making pre-loaded Raspberry Pi image

If you want to install a Raspberry Pi for some purpose, you will end up putting an image on an SD card and installing in the Pi. You can get pre-loaded SD cards even.

SD cards die!

You can get industrial SD cards! These have more write cycles, wide temperature range, and even have S.M.A.R.T. They are more expensive. The one thing I hear all the time with anyone using Pis is that the SD cards die. There are many good ways to reduce this - turn off some logging, log to a RAM disk, remote logging, not ever running mysql on it, and so on. But a good SD card is also a good start and I think probably worth it.

Installing an image.

So you download an image, the stretch lite is a start. I renamed to pi.img for the following examples.

Now, you install it on a memory card. The instructions for Mac are simple, and involve using a dd command. Important, on a Mac, is use the /dev/rdiskN not /dev/diskN as it is massively faster (character and block device versions of the raw disk access). You have to eject/unmount it before you can do the dd, and once you have finished...

sudo dd if=pi.img of=/dev/rdisk4

You end up with a bootable Debian image on you Pi. Yay!

Making a custom image?

There are ways to make a customer image, e.g. www.pibakery.org which allow you to make the image you want to start with, but there may be further tweaks you want to the image itself, and the following shows a way to do that.

You cannot ssh to it!

This is a pain, you have to find a monitor, HDMI cable, keyboard, and faff about. I want an image I can ssh to. I understand why it is not the default, but if you are making something headless you need to be able to ssh to it.

The trick here is changing the image. However, as this is a complete "disk" image with partition table and boot and main partitions, you cannot simply mount it, you have to mount part of it.

First off, find the partitions. There are normally two - a boot and a linux partition.

excalibur:/tmp# fdisk -l pi.img
Disk pi.img: 1.7 GiB, 1858076672 bytes, 3629056 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x37665771

Device     Boot Start     End Sectors  Size Id Type
pi.img1          8192   93236   85045 41.5M  c W95 FAT32 (LBA)
pi.img2         94208 3629055 3534848  1.7G 83 Linux

To allow booting you are going to want to mount the boot partition and add a file to it.. You need the start and size of the boot partition. As they are in sectors multiple by 512.

excalibur:/tmp# bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
8192*512
4194304
85045*512
43543040

And then you can mount...

excalibur:/tmp# mkdir boot
excalibur:/tmp# mount -v -o offset=4194304,sizelimit=43543040 -t vfat pi.img boot
mount: /dev/loop0 mounted on /tmp/boot.

Then all you have to do is create a file called ssh in the boot partition.

excalibur:/tmp# touch boot/ssh

And unmount

excalibur:/tmp# umount boot

Now you have an image that will boot and allow ssh, yah...

Pre-installing some stuff...

I also wanted to change the default password, add ssh keys, update the Debian install, and pre-install a few things. Now, you can do this on a Pi, i.e. install the image, ssh in, and do stuff, but then how do you make an image of that to put on the next Pi? Well, you could image your SD, but that can be 8G, 16G or 32G or whatever, and also ends up not working on another SD some of the time. What I wanted was a clean (small) image that I could install on an SD with some pre-installed stuff.

The trick is very much as above, mount the image, but to do anything you have to be running on a Pi, so I ended up with a running Pi, and loading the image on to that Pi itself, and then on the Pi I mounted the image. Yes, Russian dolls come to mind.

This time we just need the start of the linux partition.

excalibur:/tmp# bc

bc 1.06.95

Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
94208*512
48234496

And then you mount.

excalibur:/tmp# mkdir pi

excalibur:/tmp# mount -v -o offset=48234496 -t ext4 pi.img pi

mount: /dev/loop0 mounted on /tmp/pi.

Then you chroot in to it

excalibur:/tmp# chroot pi

At this point you are running in a new root file system. You can run commands like passwd, and
apt-get and so on as normal. When you have finished, simply exit the chroot and unmount...

excalibur:/tmp# umount pi

And now you have an image that has stuff pre-installed, with the right password or ssh keys as you have installed, all ready to go.

Tindie vs Amazon

Amazon have been an interesting place to sell, and have sold quite a few things. But oddly the main thing that sells is the Faikin boards. I...