# Tag Archives: Coding

Tutorial

## Rotations…

In a previous post I showed how complex numbers are useful when rotating co-ordinates and since then I’ve hard coded several geometrical translation and rotation routines that have been crude, but functional in Mathematica.  Nothing too complex, but a nice little achievement, working with matrices and manipulations.

But the scary thing about a big program like Mathematica, is that it has lots of built in functions that whilst incredibly well documented, you have to be aware that they exist before you can start to search for them.

The transformation matrices scripted above, can be automated using some of the inbuilt functions in Mathematica 9.  So for example if I wanted to rotate some co-ordinates about the z-axis the syntax is quite straightforward and can be taken from the documentation.  Rotating 4 co-ordinates (a) around the z axis (b) to give the newly updated co-ordinates (c).

There are quite a few neat and compact examples over on the documentation website if you’re interested.

I personally struggle with Mathematica at times, not because the documentation is poor, but because the scope is so vast.  But with helpful sites such as Stack Exchange or the Wolfram Community Page I’m sure I’ll start to work my way through some of the more hardcore functions given time.

Teaching

## Code…

I’m spending a lot of my time tinkering in Mathematica lately, with two objectives really.

1.) I want to write some code to calculate the tedious geometrical aspects for me for my research.

2.) I think that Mathematica has some real potential for students who are trying to learn structures, particularly through the CDF files.

I’ve learned various programming languages over the years most of which I’ve taught myself, admittedly not to the level that perhaps a computer programmer would, but I’ve armed myself with just enough knowledge to be dangerous and get the task done that I want to achieve.  I’ve created countless spreadsheets that can do all sorts of elaborate calculations and also to use as validation calculations for more complex analysis models that I’ve created.

This is a skill that I take for granted for engineers, particularly of my age, and in most engineers that are a couple of years older or so I tend to find that they’ve spent some time abusing Fortran code in some fashion.  Fortran isn’t a language that I’ve ever learned, but it’s probably one of those languages that a lot of engineers have dabbled with at some point.

One trend I’ve noticed in a lot of younger engineers is a reluctance to create computer code and indeed even in creating what I would consider simple spreadsheets to make a calculation tool that can run several scenarios for them and validate an approach to determine the boundaries of their calculations.  Increasingly there seems to be a preponderancy for young engineers to select their FEM weapon of choice and throw triangles at it until the model begs for mercy, or to download an app that some other bright spark has written to do at least part of the process of what they want to happen.  None of this promotes a deeper understanding of how the process works though unfortunately.

Perhaps the days of writing your own code are long gone for young engineers? But part of me thinks that they are missing out on a real opportunity to structure their understanding of the steps needed to do certain tasks as they assemble their code.  Writing code to perform a task, whether on a spreadsheet or in a more formal programming language, is a great way to develop understanding and to explore the intricacies of design codes and I feel that younger engineers are missing out on this experience by only using off the shelf packages.

One encouraging aspect is that with the launch of the Raspberry Pi I can see that if this continues to gather momentum that younger generations will again an ability to tinker and break programming code and gain an appreciation of the advantages that breaking down engineering problems into a series of procedural steps can bring.

At least for the next year or so I’m still responsible for sculpting young engineers minds and I’m determined to develop a fun way of getting them to extend their understanding of how to write code or spreadsheets, I just need to work out a way of doing this within the confines of the resources I do or don’t have available.

What do you think? Should engineers know how to programme or at least be able to create simple spreadsheets?