OU blog

Personal Blogs

neil

Got it I think

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 10 Aug 2011, 15:20

It's a mess, needs optimized, I need to pseudo-overload it and tidy up my messes, but hey, I have a function that composes permutations!

<html>
<head>
<title>Permutation</title>
</head>
<body>
<script type="text/javascript">
/*
Signature:
Array [Array int || int] X int -->boolean
post:
true if the int is in the permutation
*/

function contains(arr, val){
var found = false, over = false, ret = false
var ix = 0;
while(!found && !over){
if(typeof arr[ix] == 'object'){    //a cycle
var subArr = contains(arr[ix], val);
ret = subArr;
found = subArr;
ix++;
}
else{   
if(arr[ix] == val){
ret = true;
found = true;
}
else if(ix++ >= arr.length){
over = true;
}
}
}
return ret;
}


/*
Signature:
Array int X int --> int
Post:
the int after val
the first int in the array if val is the last member of the array
val if the array doesn't contain int
*/

function findNextInCycle(arr, val){
var len = arr.length;
for(var i = 0; i < len; i++){
if(arr[i] == val){ //we have the value
if(i == len - 1){ //end of the permutation return the first
return arr[0];
}
else{ //return the next value
return arr[i + 1];
}
}
}
return val; //val didn't exist in the permutation
}

/*
Signature:
Array [Array int || int] X int --> boolean
Pre:
Either an array of int representing a single cycle
or an array of array(int) with any fixed points excluded
ie [1,2,3] or [[1,3], [2,4]] but not [[1,2], 3, 4]
the last should be [1,2]
Post:
the int after val
the first int in the array if val is the last member of the array
val if the array doesn't contain int
*/

//uses findNextInCycle
function findNextInPerm(arr, val){
if(contains(arr, val)){
for(var i = 0; i < arr.length; i++){
if(typeof arr[i] == 'object'){ //an array hand it off to findNextInCycle
if(contains(arr[i], val)){
return findNextInCycle(arr[i], val);
} //otherwise we carry on through the cycles
}
else{ //hand the whole thing off to findNextInCycle
return findNextInCycle(arr, val);   
}
}
}
else{
return val;
}
}


/*
Signature:
Array [Array int] --> Array int || Array [Array int]
Post:
If the argument contains only a single array it will return that
Otherwise it will return an array with all single length cycles removed
*/

function fixCycles(arr){
if(arr.length == 1){
return arr[0];
}
else{
var ret = [];
for (cycle in arr){
if(arr[cycle].length > 1){
ret.push(arr[cycle]);
}
}
return ret;
}
}



/*
Signature:
Array [Array int || int] X Array [Array int || int] --> Array Array int
Pre:
The arrays must be either of int representing single cycles
or arrays of array(int) with any fixed points excluded
ie for either array [1,2,3] or [[1,3], [2,4]] but not [[1,2], 3, 4]
the last should be [1,2]
Post:
a composition of permutations
Use the fixCycles function to change this into a single permutaion

Note:
We need len because we may not have all numbers may appear in the perms
*/

function composePerms(first, second, len){
var ret = [], cache = [];
for(var i = 1; i <= len; i++){
if(!contains(ret, i)){
var at = i;
while(!contains(cache, at)){
cache.push(at);
at = findNextInPerm(first, findNextInPerm(second, at));
}   
ret.push(cache);
cache = []; //reset
}
}
return ret;       
}

var x = fixCycles(composePerms([1,2,4,3,5], [1,2,3,5,4], 5));
for(i in x){
document.writeln(x[i]);
} //1 4 2 5 3

// -->
</script>
</body>
</html>

Now I need to write the unit tests, and a test suite.

Permalink 2 comments (latest comment by Neil Anderson, Wednesday, 10 Aug 2011, 20:09)
Share post
neil

failure

Visible to anyone in the world
Edited by Neil Anderson, Tuesday, 9 Aug 2011, 19:27

Today I tried to write some Javascript that would allow me to compose permutations; I got an idea that I wanted to bulk test.

[I should be working on analysis but my mind and fingers itch for groups.]

It was surprisingly hard—because I tackled it stupidly, I didn't write a specification and I've lost my test harness somewhere along the road.

The beast is still in the myth stage.

I will manage this, but my uselessness, after all this study, annoys me hugely. And why do I rely on code [that I can't write] to confirm something that I should be able to prove

Permalink Add your comment
Share post
neil

compulsory mathematics

Visible to anyone in the world

We are having a discussion about compulsory maths on M208. Here is one of my posts...

Numeracy is obviously important, you should have to keep doing it until you reach a certain level. Rather like a driving exam.

But how useful is maths? I suppose that the standard reply would be that it promotes logical, rigorous reasoning. In certain contexts. But real maths? Some of us can do it, some of us can't; making it compulsory? Why not make history compulsory?

History I hear you scream! But think, the ability to read several accounts of the same event by different people, sift the truth and craft a coherent narrative. That ain't no small skill.

My point is that most subjects could make an argument for being vital at developing a certain type of skill. I would suggest that it rather depends on the child. If you can get a child enthused about any subject at eighteen then I think that you've probably done a good job of educating them.

Too often I hear that our schools are failing, in what way? Usually if you ask the question, after some waffle, you'll get, "children lack basic literacy and numeracy skills". At which point I suggest that for some children it makes little sense to acquire them: strive how they will there won't be a job for them. If you are poor you won't be getting a degree, and even if you do you won't have the contacts to get the job.

There's no incentive for a whole swathe of children to learn anything. Unless you tackle that problem there's little point in bandying around the word compulsion. You can't legislate knowledge.

Permalink Add your comment
Share post
neil

More books

Visible to anyone in the world
Edited by Neil Anderson, Monday, 8 Aug 2011, 18:11

I managed to acquire...

But best of all I got, A course of Pure Mathematics G H Hardy.

They sit next to me in a pile that I fondly glance at once a minute I guess. [Hardy I'm reading.] 

Of all the things in this world, barring anything living, I do love books the best. I'm now old-fashioned but if books stop existing we will lose so much; we will have everything always available and nothing to hunt for. That is a truly sorry place for a human to be.

Permalink Add your comment
Share post
neil

I'm going to do something stupid

Visible to anyone in the world
Edited by Neil Anderson, Friday, 5 Aug 2011, 12:08
So I'm working on a justification.
Permalink 1 comment (latest comment by Wren Tyler, Friday, 5 Aug 2011, 20:07)
Share post
neil

Found

Visible to anyone in the world
Edited by Neil Anderson, Thursday, 4 Aug 2011, 19:27
From who knows where I found an old copy of 'nine stories' by Salinger. I guess that I'm not going to be rich [it's a nth edition signet] still happy, and not a nutter. 
Permalink Add your comment
Share post
neil

At some point

Visible to anyone in the world

You may do what I have just done—make a stupid post that you can't retract. Here's how to react: scream a wee bit; strangely it helps.

For me I need to remember that I'm an idiot in a realm of giants; but we need idiots, I serve a point.

n

Permalink 3 comments (latest comment by Wren Tyler, Thursday, 4 Aug 2011, 17:48)
Share post
neil

Result

Visible to anyone in the world
Edited by Neil Anderson, Tuesday, 2 Aug 2011, 14:07

Got a grade 2 for M257, 81 for the OES, 4 marks short of a distinction. Shouldn't have walked out of the exam after only 2 hours then should I!

Still, very pleased. The exam contained many sections that could be termed waffly where marks could ooze away easily. Such is the way with exams [and CMAs]. You just have to accept that this is the way of things.

What's slightly annoying is that it doesn't seem that we are going to be getting any feedback about our marks. I do like to wallow in my errors.

Another 20 points on the road!

Permalink 7 comments (latest comment by Neil Anderson, Wednesday, 3 Aug 2011, 15:36)
Share post
neil

More analysis

Visible to anyone in the world
This time of my plans for my analysis.
Permalink 2 comments (latest comment by Neil Anderson, Tuesday, 2 Aug 2011, 13:42)
Share post
neil

Scoobied

Visible to anyone in the world

This afternoon I squatted in my garden, in the sun, moving the few heavy things that I had upon my person [the stabby-murder craft knife, my bottle of pimms, my bottle of lemonade] onto the bits of paper where I was trying to make sense of these counting problems. When I forgot to do this my groups winged there way into an uncaring world.

Best day for ages.

Permalink 3 comments (latest comment by Wren Tyler, Sunday, 31 Jul 2011, 20:50)
Share post
neil

Colouring

Visible to anyone in the world
Edited by Neil Anderson, Saturday, 30 Jul 2011, 12:38

I should be doing analysis if I'm doing maths, but I've become obsessed by colouring problems. I'm determined to find a general algorithm.

The problem involves a lot of subtleties; take, for example a hexagon, how many ways are there to divide it into 2, 3, 4, 6, equal areas, can we divide into 5? Are primes involved here?

For the first time in ages I'm working at something for myself, and working at maths with a view to writing a programme. This is good.

I won't manage this, but sometimes the exercise is more important than the result. And in the back of my head I'm thinking solitaire.

Permalink 2 comments (latest comment by Neil Anderson, Sunday, 31 Jul 2011, 05:52)
Share post
neil

Found!

Visible to anyone in the world
I think, where my limits lie.
Permalink Add your comment
Share post
neil

Navel gazing

Visible to anyone in the world
As always, but I do think that I might be getting somewhere slowly.
Permalink Add your comment
Share post
neil

I couldn't

Visible to anyone in the world

Bring myself to work at completing my group theory TMA today, and I realized that there are important concepts unlearnt during my task-displacement walk.

Stuffed is what I am

Permalink 6 comments (latest comment by Neil Anderson, Monday, 25 Jul 2011, 20:30)
Share post
neil

Getting it?

Visible to anyone in the world
Probably not, but at least I'm beginning to realize that I may be lying to myself.
Permalink 1 comment (latest comment by Wren Tyler, Friday, 22 Jul 2011, 12:58)
Share post
neil

Bang!!

Visible to anyone in the world
Edited by Neil Anderson, Monday, 18 Jul 2011, 19:14

2011–07–18

lightning…

I was on holiday last week—a peaceful week of maths, gardening and drinking had been planned; and not too much messing with computers, some of course.

My holiday started Friday afternoon, my mother-in-law was visiting, we had a risotto with the first home-grown peas of the season and a garden salad [pretty good I thought], I had an afternoon bottle of wine and then we watched the exciting thunderstorm from the front door. Right up until the lightning hit the scaffolding in the playground about twenty-feet away from us. [I live in a playground].

I’ve never been that close to a lightning strike before, the sky flashed, the scaffolding fizzed and the noise—thunder, crack-crash and power. We didn’t think it was so much fun after that.

Now, I’d remembered to unplug the computers but…when the phone, the broadband and eventually television shut down. Oh dear. You need to unplug your phone-line too it seems.

It’s one thing planning to not use your computer when you have one to use, it’s quite another when you can’t. And my wife was cut-off too! This was serious.

technical support

Is always a bad-beast to deal with, but when you aren’t online, don’t have a landline, have only freeview crap to watch on television; when you can almost see the money leaking from your mobile as the muzak plays… I won’t regale you with the whole sorry saga of the hellish mess that I was sucked into.

My wife and I spent a lot of time, and money, in wifi-enabled pubs, her on the internet, me getting drunk enough to vent a proper fury upon the hapless employees of the useless for my plight.

After a couple of days and what seemed like a hundred phone-calls the truth dawned—it was all lies, people will say anything to get rid of you. [That rubbish about recording calls to provide a better service is just that—rubbish. All they want is an oppertunity to make you an unwilling YouTube star.]

So I gave in and bought a dongle. And then I, drunkenly, watched that eat my money too. Like me in my cups it was a slow and greedy thing.

The new hub arrived today [Ten days, six days after promised], I can hear thunder in the distance and I’m fretting. How close do I let it get?

 

Still, not too bad a holiday—at least I wasn’t interrupted by the phone and I achieved a third of my ambitions, in a spectacular way.

More than I usually do.

Permalink 6 comments (latest comment by Neil Anderson, Wednesday, 3 Aug 2011, 15:39)
Share post
neil

Why blog

Visible to anyone in the world

well, why I blog[3]

You may change somebody’s life.

Maths and I will never be parted again. I stumbled into the OU via an odd route; I started maths due to a single conversation with a fellow student. He changed my life, I’ll forever be thankful to Paul.

This seems like a staggering responsibility—it isn’t. If we strive to tell it like it is and behave in a proper manner we [us bloggers] are doing our jobs. We came to the OU to make ourselves better, it will, but often in a way that we hadn’t foreseen—we may make someone else’s life richer too.

Permalink Add your comment
Share post
neil

Why Blog

Visible to anyone in the world
Edited by Neil Anderson, Thursday, 7 Jul 2011, 11:54

well, why I blog[2]

My school has an embedded police-person, he said to me once, “my first partner told me to slow down…if you are walking too fast you aren’t watching”. Life is like that—it’s easy to let it go past without enjoying it.

Every morning and evening I walk along the canal, dodging the joggers and cyclists who don’t see what I see—the wild-flowers, the bees, the kingfisher, the perch, the big pike, the day spring arrives, the day autumn comes…they are going too fast. That’s [partly] what blogging is—looking, properly, at your life and remembering it for future reference.

Let’s take my M208 as an example: reading my posts back I see a pattern—a nagging sense of dissatisfaction with myself. Why? Aye, there’s the rub—there’s the looking and then there’s understanding. If you don’t read your own stuff back and reflect then you’ve missed half the point—blogging gives you a platform to make you better. So…

Partly, I think, that it’s down to my lack of technique, I’m a great fan of technique. [I can do some of the working, but it doesn’t come naturally.] So far, with maths, I’ve been reliant on the technique that I learnt at school, where I understood nothing. Now I’m grasping at the understanding without having developed the technique. I feel unsafe.

Developing technique takes time and effort, I haven’t made the time or the effort; I think that I need to. I could just ignore this and still pass, but that’s what I’ve been doing—‘working’ the course rather that working at it. I’m doing this [OU stuff] for me, if I fail nothing will change except my conception of me.

That’s a reason to blog—I might have come to this realization of what was wrong without it, but I suspect that I wouldn’t have. It’s easier to be honest when the person you are trying to lie to is your own words.

Permalink 1 comment (latest comment by Emily Blakey, Friday, 8 Jul 2011, 09:24)
Share post
neil

Why Blog

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 6 Jul 2011, 20:41

well, why I blog[1]

I’ve been trying, and failing, to do some M208 work over the last few of days. No work has happened—I’m too busy at work-work, too knackered-tired and too mentally-unfocused to do more than stare hopelessly at the unit texts. Bad news? Not really—I’ve been here before, many, many times. How do I know this? Because I blog and I can read what I thought then….

Blogging, for me, is akin to keeping a public diary, a diary helps when you hit the lows [or highs]—it’s a comfort to know that you have been in a similar place before. Gives you hope [or pause], and gives you a direct-tunnel into remembering the feelings that you had then. Your own writing is a form of smell/taste—you’re right back there.

Why is it important that it is public?

Because if you’re, potentially, going to splatter your thoughts across the entire ether you think a bit. And when you think, you think about what it is that you are really thinking. True, I sometimes craft a post in an attempt to make it a bit more interesting, or to reinforce a point, but in general what you read here is me. I do this for you, If I was doing this for myself it would be a stream of incoherent babble, I’ve got books and books of that.

The most important person that you’ll ever analyse is yourself. When you do there are obvious temptations to lie; if you analyse yourself in public these temptations are fewer. Why? Because in a certain sense you have to step outside yourself—you create a caricature of yourself [an avatar?] that splits you off from yourself. Despite yourself you’re tempted into relating, mostly, the truth.

I started off trying to say something entirely different here—how my M208 blog had helped me realize where I was going wrong—as you can see I didn’t, which is why I’ve labelled it [1].

Blogging, like forgiving, is for you. The very act of trying to write what it is that you feel/think is important. There are some spin-offs, we’ll talk about those next time…

Permalink 12 comments (latest comment by Nigel Timothy, Thursday, 7 Jul 2011, 02:33)
Share post
neil

Sunny day thoughts

Visible to anyone in the world
Much the same as my usual ones.
Permalink 6 comments (latest comment by Neil Anderson, Wednesday, 6 Jul 2011, 20:35)
Share post
neil

New blog post

Visible to anyone in the world

2011–07–02

better…

For the first time this year I’ve got my baseball boots on—summer has started. I had a tutorial this morning, lovely Groups. Getting to my tutorial is always fun; It goes in stages:

  1. I walk along the canal to Tolcross[ish], very bucolic—ducks, swallows, reeds, swans, dogs and the bikers who seem to be trying to end my life.
  2. I get to Tolcross[ish], the city, and head for the Grassmarket, via the West port, the second-hand-bookshop region of the town. Here I buy my old maths books, but I don’t tarry
  3. Then there’s the Grassmarket, a seething mass of tourists and drunks even at nine-thirty on a Saturday morning. Full of light and pubs
  4. The Cowgate—a shaded urban-canyon where strange pale-people stagger around looking around for the night-club they think they’ve just left
  5. You swing up towards the High Street where the world streams past
  6. You do the maths

Afterwards we go to The Task and have a drink and a catch-up chat.

After a slightly torrid-time personally I feel healed, and ravenous for maths.

Permalink 3 comments (latest comment by N D, Sunday, 3 Jul 2011, 10:36)
Share post
neil

Janie

Visible to anyone in the world
Edited by Neil Anderson, Friday, 1 Jul 2011, 13:58

A huge number of teachers are retiring today. I've said goodbye to them all in various ways.

One particular goodbye was a bit poignant—her and I didn't always see eye-to-eye, but I'm willing to forgive everything if you are a great teacher. And she was [and I'm an excellent judge]. So I gave her a bear-hug.

I hope I made her cry, I had to get out sharpish before I myself was unmanned by a shameful display of emotion.

Permalink 2 comments (latest comment by Neil Anderson, Friday, 1 Jul 2011, 15:04)
Share post
neil

The good thing...

Visible to anyone in the world
about the singles finishing early, is that you get to see more doubles.
Permalink 3 comments (latest comment by Neil Anderson, Thursday, 30 Jun 2011, 20:06)
Share post
neil

My stupid. free,

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 29 Jun 2011, 20:57

2011–06–29

analysing my analysis

It’s activity week at my school this week. Half the school is abroad, somewhere, others are concentrating on a single activity—golf, cooking, film-making…whatever.

Then there are those on the, ‘daily activity programme’. One of these activities is chess. I can’t/won’t ever walk past a room where people are playing chess without at least a wee peek. My look revealed that there were those there that couldn’t play chess at all. [Why?] I picked upon one wee girl to teach.

You teach chess by showing people how each of the pieces moves and set up the start position, right? Wrong. Here’s what you do:

  1. Set up four pawns each side, the winner is the one who gets a pawn to the eighth rank first
  2. Make sure they are comfortable with the pawns; and make sure that en passant comes up somewhere
  3. Keep adding pawns to their side until they can beat you, when you are trying
  4. Introduce the King, the idea of check and play the same game
  5. Three above
  6. Introduce the Queen, the concept of promotion and checkmate
  7. Three above et al

I’ve, probably, taught hundreds kids to play chess, or about it, and I can assure you that this is the best way for their future progress. Chess from the start-position is just a nightmare, if you haven’t grasped what it is you are trying to do. First introduce the patterns, “if I’m here, I can get there by doing that, and I can win from there…”

Anyhoo, I was going through my usual routine, the wee girl was doing well, she showed some flair [she grasped the concept of a passed-pawn and an outside-passed-pawn in a way that some quite-good players don’t]. But she had a distressing tendency to push her King up the board when she should have been gobbling pawns. Why? Because she was doing exactly what I’d told her to do—get a piece to the other side! I hadn’t made it clear that the game-rules hadn’t changed [1 above].

She was right, I was wrong, and that’s my problem when it comes to analysis.

Spot the other dodgy assumptions for yourselves.

My faultz

I got my latest TMA back today, my tutor said, something along the lines of…

Accuracy is everything in analysis…you [me—neil] often miss out parts of the argument.

Exactly what I’d done with the wee girl and the chess. I assume; you can’t do that with analysis. Or with maths in general, but particularly with analysis.

My wife was in heaven when I read this out to her. Once, I drew her a map, a map which sent her astray. I missed out a couple of streets, shouldn’t have mattered—it was obvious. She got lost, asked for help, displayed the map, the map was rubbished by a stranger. My wife has a keen intelligence, especially when it comes to my failings, she’s never ceased to bring this up.

So, I have a problem.

What to do?

I suppose I could just ignore it and carry on. We’ve another analysis block—I could catch up there? Catch up in what sense? Stopping being sloppy? More of the same won’t help there methinks.

To stick with the chess metaphor, where we started—you can be aware of the positions that you don’t like and try to avoid them, but in the end you are better fixing your flaws. Otherwise others will head for your weakness. So we must master the basics, like I teach chess.

I’m going to go back to analysis, to teach myself a discipline that I don’t have.

Permalink 10 comments (latest comment by Neil Anderson, Friday, 1 Jul 2011, 20:20)
Share post
neil

oops

Visible to anyone in the world

Done something incredibly stupid, listened to the Red Army Blues.

I won't be here for a while.

Permalink Add your comment
Share post

This blog might contain posts that are only visible to logged-in users, or where only logged-in users can comment. If you have an account on the system, please log in for full access.

Total visits to this blog: 253590