Checking – Catching Mistakes Before They Catch You

Everybody makes mistakes from time to time. It’s one of the ways we learn. It’s also something that distinguishes us from computers. When I was a very junior programmer, one of the team leaders in the office said to me, “The machine is doing exactly what you told it to do, lad. It’s just not doing what you thought you told it to do.” I repeat, everyone makes mistakes…

This week’s post is about ways of checking your work. Some of them give you an absolute guarantee that you are right. Some of them merely show that an error exists. They’re worth doing, either way.

Mental Arithmetic

Use these when you have to work it out by hand, or as checks against typos when using a calculator.

Last digit checks can highlight errors in multiplication. The most basic comes from the simple fact that you only get an odd answer when you multiply odd numbers. However big the multiplication, a single even number makes the answer even. One factor of two is all it takes… (sounds like an advertising slogan). So if you multiply a string of odd numbers and get an even answer (or vice versa), something has gone wrong.

A more sophisticated last digit multiplication check is the units make the units. For example: 27346255346277347 x 38482942904939 must have an answer ending in a 3. This is because 9 x 7 = 63 and although the 60 gets mixed in with the other tens, nothing else can affect the 3 in the units column. Try it with smaller numbers and you will see what I mean.

Ballpark estimates are always a good idea. See if your answer seems ‘about right’ by rounding to simple whole numbers. In particular, take π as 3, and gravity as 10 ms-2. In a recent lesson we looked at a question involving a stone being thrown vertically downwards from the top of a tower with initial speed 4ms-1, and taking 2 seconds to reach the ground. The problem was to find the height of the tower.

This is easy enough using s = ut + ½at2 = (4 x 2) + (½ x 9.8 x 22 ) = 27.6 m

But if you miss out the decimal point in gravity (and use 98) you get 276m as the answer. This is a tall tower, but not impossibly so.

The ballpark check 4×2 = 8, plus ½ x 10 x 4 = 20, giving 28 will highlight the error faster than you can write it down (or the stone takes to fall).

Counting minuses in multiplication (or division) is a simple way of making sure you haven’t got the sign wrong. If you have an even number of minuses, the answer is positive. If you have an odd number of minuses, the answer is negative. Easy!

Counting decimal places is worthwhile whenever you have to multiply decimals. The rule is that you always end up with the same number of d.p. that you start with. This may include trailing zeros. Here are some examples:

0.5 x 0.5 = 0.25 2 dp on either side

0.24 x 0.45 = 0.1080 4 dp on either side.           (Calculators just show 0.108)

0.02 x 0.0004 = 0.000008 5 dp on either side

In the last example, counting the d.p. on the left hand side is a quick way of determining that we need five leading zeros to bring the total d.p. to 6.

Calculator checking

Comparing answers. If you are working from a text book and checking your answers against the ones in the back, you sometimes get a situation where the forms of the answers differs.

For example you might have 0.805612004, and the book has 3e-5 + π/4.

A quick way of checking is to type in the book version, followed by divide and ANS (the button that recalls the answer you just had). If you are right, the new answer will be 1. You could make the same test by subtracting (answer = 0 if correct) but I always use division. No particular reason.

Simplifying algebra From time to time you may have to ‘simplify’ horrible pieces of algebra. For example:

Selection_009

To check this, pick a couple of easy values for x and y (Don’t choose anything that will lead you to divide by zero!). So with x = 1 and y = 2, we have:

Selection_010which gives Selection_011

It only takes a few seconds to type this into your calculator using the fractions button. You could even do it by comparing answers by entering:

Selection_012 (there’s now a minus in the middle)

This gives an answer of zero straight away.

Checking solutions to equations is easy with a calculator if you use the memory to hold variables. (I am assuming you have a typical school scientific calculator such as a Casio fx-83GT).

Step 1 Assign the value you want to check to the variable X by entering the value then pressing shift, RCL, ). For example:

7 Shift RCL ) sets X to 7.

You don’t need to press =. The display shows 7X at the top. Any previous X value is overwritten.

Step 2 Enter your expression, using the Alpha button whenever you want X.

Alpha ) x2 – 2 Alpha ) + 3 gives you x2 + 2x + 3

Step 3 Now press =. The calculator works out 72 – (2×7) + 3 to give 38.

Step 4 Now press AC, then enter the next value you want to test. For example:

5 Shift RCL ) sets X to 5.

Step 5 Press the up arrow. (This scrolls you back through previous actions). The expression x2 + 2x + 3 will reappear. Now press = again, to get the answer with X = 5.

You can do this as many times as you want, and if you are dealing with awkward decimals or surds it is quicker than typing them into the expression directly. It’s probably overkill at GCSE but can be a great help at A level where you often have equations with multiple solutions. (Tip If you aren’t sure of the current value of X, press Alpha ) = to display it.)

These are just some useful checking tricks. Maybe you have your own favourites you would like to share.

Going Live With Linux

I’ve been pretty happy with Windows Vista.

There, I said it. Duck me in the village pond then burn me at the stake.

I bought a HP Pavilion dv9000 laptop with Vista preinstalled when it was brand new. I nearly had the shop give me XP instead, but then I thought about future support and upgrades and the hassle of keeping an old system going against the grain… So I accepted Vista and, after the ups and downs of the first few months, it has served me well. I’ve used the laptop for work and basic web surfing and shopping, and it’s still my typewriter of choice for large projects.

A year ago, I installed Pinguy Linux on the family desktop (in a partition alongside the kids’ old Vista machine, which nobody ever uses but I’m not allowed to get rid of) and since then I hardly connect the laptop to the internet. It’s still fine as a standalone office machine, but can be desperately slow on line. And then there’s all the endless updating. Pinguy has everything I need for day to day work, runs fast and updates in a couple of minutes if you do it regularly.

I tried running the laptop from my Pinguy installation disc in live mode. For anyone unfamiliar with the jargon, this means the operating system runs in RAM and nothing gets written to your computer drive. Great for testing. It worked, but not well. The laptop only has 2Mb of RAM, which isn’t enough for a full Pinguy system. My live/install version of Pinguy also lacks the Nvidia drivers the laptop needs, so I had to edit the boot parameters to force vesa. (I’m not going to explain this – there are lots of good threads on the web if you need help on editing the boot string in a Grub menu. Besides, the whole point of this article is to ensure you won’t have to!) I considered partitioning the hard drive, but was unable to free a decent amount of space without manually resizing partitions. I chickened out at this point – I have a clean and useful Vista system which I still use regularly for writing and things like Graph (https://www.padowan.dk/download/ ) that don’t run under Linux (I’m not a fan of Wine), and if it ain’t broke I prefer not to fix it.

At this point, I asked myself what I really wanted. The answers were:

1) Vista working on the laptop. (So leave it alone!)

2) The ability to connect the laptop to the internet without too much fuss and updating. (Won’t do this often, but never say never).

3) Getting Linux working on the laptop. (Pride!)

4) Trying a few other Linux distros. (I love Pinguy, but you can’t help being curious.) ‘Distro’ is shorthand for ‘distribution’ – in other words a particular bundle of Linux and associated software.

The obvious solution was to create a multiboot usb stick, with a selection of lightweight distros, and then have a play. The rest of this article describes what I did and compares some features of the distros I tried.

First a little technical caveat. My laptop is a HP Pavilion dv9000 with 2Mb of RAM, an AMD Athlon X2 64 bit processor and an Nvidia GeForce7150M/nForce630M graphics processor. And I’m an ordinary computer user, capable of reading a help thread and a manual, and typing commands at a terminal prompt, but no kind of tech guru. So there are probably lots of better ways of doing the job, and a different machine might need different things. This worked for me and I hope it works for you, but no guarantees, OK?

Choosing Distros

I wanted an operating system light enough to run in 2Mb of RAM and with appropriate Nvidia drivers installed as standard. It should allow me to connect to the internet (wirelessly if possible), check my email, edit a document locally or on the Cloud and watch video on You Tube. I expect to have to tweak a live system a little before actually using it, for example to turn on a firewall, but the less the better.

After reading lots of reviews (and this is my way of saying thanks, guys) I decided on the following:

Puppy Linux:    Puppy 5.2.8 Lucid from ibiblio.org via the link from

http://puppylinux.org/main/Long-Term-Supported%20Puppy.htm#lucidpuppy

Kanotix:   Kanotix Dragonfire LinuxTag2013 LXDE version from

http://www.kanotix.com/changelang-eng.html

PCLinuxOS.    The lxde 2014 version via the website

http://www.pclinuxos.com/get-pclinuxos/

(I used one of the Irish mirror sites for the download)

Lubuntu.     The 64 bit AMD version via

http://lubuntu.net/blog/lubuntu-1504-vivid-vervet-released

Porteus.     Porteus is a bit different. You specify in advance many of the things that other distros require you to set or install after booting. Go to http://www.porteus.org/ and follow the instructions.

I chose the LXQt desktop, Nvidia Legacy drivers and Firefox as defaults, and said ‘No’ to things like a VOIP client (for Skype) development tools and printing support. This gave me a very lean system.

A couple of general points.

I chose a light desktop – so LXDE or LXQt rather than KDE. However, the distros are so light in general that I am fairly sure you could go for KDE without having a huge impact on performance.

I saved the .iso files (the images of the OS) to a sub folder in my Downloads folder, just to be tidy. The file sizes were: Puppy Linux 139 Mb, Kanotix 785 Mb, PCLinuxOS 715 Mb, Lubuntu 724 Mb and my basic Porteus distro 260Mb.

As you can see, Puppy is the smallest by a good margin. Lighter distros exist, but I wasn’t confident they would have everything I wanted.

I have a 64 bit machine, so I chose 64 bit distros even though I only have a 32 bit version of Vista. All the above distros come in 32 bit flavours if that’s what you need.

Creating the Multiboot USB

I used Multisystem LiveUSB which has a version designed to run in Linux, as I wanted to create the boot usb on my Linux desktop machine. Other options are available if you are working with a Windows system.

(NOTE Multisystem is French software, but their website translates into pretty much any language you like, including Welsh. Da iawn a ddiolch, ffrindiau! If you don’t want to download your own distros, they will sell you a stick with a selection already installed. If you are following what I did, you won’t need to go there at all).

1) Search for MultiSystem LiveUSB.

2) Follow the link to pendrivelinux.com:

http://www.pendrivelinux.com/multiboot-create-a-multiboot-usb-from-linux/

3) The window now has all you need. Click on the download link in paragraph 1, then follow the instructions. The installation shell script will be placed on your desktop and when you run it the package is installed. This takes a few minutes. In my Pinguy setup, Multisystem ends up in the Accessories section of the menu. There is also a tool to test an iso file, which I didn’t try but might come in handy.

4) Once you have installed the software, follow the instructions in the lower half of the window to create your usb drive. Some additional pointers (please bear in mind I was doing this from Linux, not Windows):

  • I had to format my new usb before Multisystem would recognise it. I used the Ubuntu ‘Discs’ utility to create an 8 GB partition on a 16Gb stick, give it a label and mount it, after which Multisystem detected it immediately. The five distros I installed, plus the associated tools that Multisystem includes, came to about 2.7Gb in total, which is 100Mb more than the sum of the .iso file sizes. So you don’t need a massive usb stick.

  • The device came up as /dev/sdf1. This will probably be different for you – make sure you are installing to the correct place!

  • Open a file manager alongside Multisystem, then drag and drop your .iso files from there. (There is no built in ‘browse’ facility.) This needs a root level (sudo) command so you have to enter your root password each time.

  • The copy runs in a terminal window, and what you see varies from distro to distro. BE PATIENT – it will take several minutes for each distro.

  • Just quit at the end. There is no ‘finalise’ step – so I suspect you can add more distros later if you want, although I haven’t tried this.

Booting from the live usb drive

Insert the drive, then start your machine. As it begins to boot, press F9 (on my two computers) a few times to open the boot menu and choose your boot device. On my desktop, it is recognised as ‘USB Pen Drive’ but on my laptop it is ‘USB Hard Drive’. Consistency, thy name is Hewlett Packard! If you are going to be booting from the stick often, it would be worth editing the BIOS to choose the appropriate drive before the hard disc, but I advise checking first via F9. (I edited the laptop BIOS in advance to choose pen drive, which didn’t work. Took me a while to figure that one out).

P1000139

You will now see the Grub menu (something like the photo above), giving a selection of Linux installations and some other system tools. Simply pick the one you want and you’re in business. Lubuntu gives you the choice of booting live or installing the software (choose ‘Try’ to begin with), the others just boot up. If you like what you see, you can install it later.

NOTE The photo shows Kanotix, Lubuntu, Puppy Linux, and PCLinuxOS as the first four entries.  Porteus is displayed as Syslinux. Select this to get another screen, then press Enter when Porteus is highlighted on the top line. My installation prompts for ‘Always fresh’ (i.e. don’t save anything) during startup. There is an option to preselect this on the Porteus menu screen, but when I tried that the boot ran part way, then hung. So just press Enter.

As you would expect, the lighter distros boot faster, but none of them takes more than a minute for me except PCLinuxOS, which requires about 2.5 minutes. They all shut down very quickly, unless you have applied an option to save settings.

First Impressions

First up, they all work. You get a functioning Linux system that you can adapt to your needs. They all connect to the internet if you plug them in. And they are FAST – especially compared to a creaky old Vista system. Puppy is so fast that you might have to reduce the mouse sensitivity to stop it selecting things all by itself as you pass over them.

I’m not going to say much about appearance, as you would want to customise all of them for extended use. PCLinuxOS, Lubuntu and Porteus have modern minimalist desktops, all nice looking and easy to use once you learn where everything is in the menu structure. Puppy Linux puts icons on the desktop for the most common tasks which I found helpful to begin with. Kanotix reminds me a little of older versions of Windows, or the desktop on my Raspberry Pi, which is also based on Debian. (I think the others are all Ubuntu based.) Lubuntu is the prettiest at first sight but I could live with any of them.

I had no problems with video drivers on my laptop. Everything is clear and sharp and works as you would expect. When I try the live usb systems in my desktop, which has a Radeon graphics card, I get slightly different results. SO… if you are thinking of using a usb live system to move between several machines, you will probably have to do some tinkering to get everything just the way you want it.

The sound is good on all the distros except Kanotix, which is a bit crackly. That may be because I haven’t spent enough time adjusting settings, but as my aim is to find a distro that needs minimum tweaking… I’m typing this on one machine while listening to Cream on headphones through You Tube running on Puppy on the other. Awesome!

Word Processing

If you are planning to do much typing, you will want a word processor on the computer.

PCLinuxOS, Lubuntu and Puppy Linux come with Abiword included. This seems fine on first trial, although if I was installing to the hard disc rather than running from the live usb I would definitely add Libre Office. Puppy has a menu item to download this. Kanotix and Porteus only come with the Leafpad text editor. (I could have sworn I asked for Porteus to include Libre Office. Either I clicked the wrong button, or the build didn’t work.)

Alternatively, you could use something like Onedrive, which gives you MS Word on the Cloud. I occasionally do this if I want to share a document between my iPad and another computer, and it works very well. (Other Cloud options are available!)

Internet Connection

All five distros work perfectly with the internet if you are plugged into your router.

Only Puppy and Porteus give simple access to our wireless network at home – select service, then enter password. The other three distros require you to set up the router connection from scratch. This is not hard, if you haven’t lost all the information that came when you bought the router, but I wouldn’t want to do it every time I logged in.

I used the ‘save settings’ option when shutting down Puppy, and after this could connect wirelessly without entering the password again. I’m sure the same would be true if I made any of the other distros persistent after setting up wireless connectivity. (See below for more on persistence).

None of the distros activates a firewall automatically, but it’s pretty easy to do once you find where it is hiding. On line help is a wonderful thing! After I saved my settings, Puppy started the firewall on the next boot.

Web Browser

Lubuntu and PCLinuxOS come with Firefox. Kanotix has Iceweasel, which is very similar. When I created the Porteus .iso file, I requested Firefox (Chrome and Opera are also available as defaults). You can, of course, add any other browser you like once the system is loaded.

Puppy does things differently, providing the lightweight browser Dillo by default and offering a choice of Firefox, Seamonkey, Chromium and Opera via the Quickpets package manager on the desktop. This is a simplified package manager that gives access to the packages you are most likely to need at the outset. As Dillo did not work straight away, I went mad, installed all four bigger browsers and spent a happy hour playing with them. They only take a couple of minutes each to install, so it would be no great hassle to download one every time, but in the end I restarted and loaded Chromium before saving my settings. If you are running Puppy on a very old machine, you might need Dillo but you will have to spend some time setting it up. It works well enough on my Raspberry Pi.

I watch music videos quite a lot, and get pretty fed up with the Flash plug-in message. All the systems here played You Tube videos without requiring any tweaking. (Lubuntu and Kanotix requested the plug-in, then worked anyway without me doing anything.)

NOTE If you are doing serious work on your system and saving stuff, you will want to make sure your browser has the latest version of Flash (which I think means using Chrome or installing the Flash plug-in to Chromium) to avoid security vulnerabilities. Alternatively, only play video that doesn’t require Flash or install a ‘video without Flash’ add-on to Firefox. Having said that, running from a live usb means that everything gets lost at shutdown (as long as it’s NOT persistent!) so you don’t really need to worry too much.

Internet history is saved in Puppy once ‘save settings’ has been turned on. If you don’t want this, you can configure the browser not to keep history in the usual way

Customization

My aim was to find a distro that ran from a live usb on my laptop with the bare minimum of adaptation, so I haven’t spent any time finding exciting software and adding it. However, here are some observations:

  • Puppy makes it very easy to find the things you might want to add at the start via Quickpet, and it’s so small that you can try various options quickly, then reboot to get rid of them. There is also a Setup menu option which takes you to a list of wizards for customizing the sound card, printers and so on. I didn’t need this, as the tasks I absolutely had to do were prompted when I first loaded Puppy.

  • Porteus requires you to log in as root for most system related work. The password is ‘toor’.

  • ALL Linux systems are almost infinitely customizable (I think that’s a word…), so whatever you start with you can create the system of your dreams. At least in theory.

  • Bear in mind that if you really want to customize your system, you will have to make it persistent or install it to your hard drive.

Persistence

Persistence preserves your settings (including firewall), internet connection details and internet history. I was also able to save files to the usb or the hard drive, and I don’t think persistence affects those one way or the other.

I made Puppy persistent as an experiment, but I’m unsure whether I would bother with a persistent live usb otherwise. The idea that you can transfer your system and settings to any machine is great. Unfortunately, once I had saved my Puppy settings on the laptop the system didn’t work as well on my desktop as it had the first time round. (Something happened to make the screen very dark). And I have a nasty feeling that correcting this could easily have resulted in those settings being saved, giving me a problem the next time I boot the laptop into Puppy. So it’s probably best NOT to make your live usb system persistent unless you only ever intend to use it on one model of machine.

Ask yourself why you might want persistence. If it’s because you have to have your system just so all the time, then you might be better off with a permanent installation. The great advantage of a Linux live disc or usb is that you can use it as a starting point on any machine, quickly add the packages you need to get running, do what you need to and move on. I imagine tech support people have dozens of distros in almost every version possible, and know from experience exactly what to use where. They may want persistence now and again, and they are expert enough not to screw things up. I’m not sure I trust myself that much!

Finally, saving settings takes time. Non-persistent live Linux systems shut down in a few seconds as nothing is being saved. Puppy Linux with ‘save settings’ takes a minute or two.

Conclusion

As you have probably gathered, I’m very impressed with Puppy Linux, and it will be my distro of choice when using the laptop on the internet. I’ve made it persistent, but I can live with that. When Vista finally turns up its toes or I don’t want it any more, I will install some form of Linux on the machine and it might well be Puppy.

A very strong second choice would be Porteus. Fast, good looking and detected our wireless router straight away. I like the way you can choose features before creating your .iso file.

If you’ve got this far, you are probably considering trying Linux on an old laptop. Any of the five distros I have discussed would be a good starting point. Try them on a live stick – and if you don’t like them, download something else instead.  Good luck!