Eiteog

Back

\[ \]

\[ \]

\[ \]

Four Codes for Solving Mathematics

Issue No 19, 6 March 2023

By: Anthony O. Ives

If truth be told I don't really like computers and try to spend as little time as possible on them. I'd rather be flying, swimming, doing some other outdoor activity or building something. However, computers claim to make our lives easier if they do what they are suppose to. The thing that I enjoy doing the most of on a computer is programming especially solving mathematical problems. I have always liked mathematics its probably the only purely academic subject that I was ever good at. Computers open up the possibility of solving complex equations using numerical methods. Numerical methods use thousands, millions or more of simple arithmetic calcuations to solve complex equations that could not be solved in an exact way. In this article I am going to introduce you to four useful codes for solving mathematics and creating your own custom software. Most of the codes use tools that are freely available.

Some advice points when using computers in general more so when programming:

  1. Seat, Desk and Posture - Make sure your desk and seat are adjusted correctly that you are not doing damage to your back, I have personally experienced back problems which I believe can be attributed to sitting at computers too long probably with the wrong setup. More details can found on the internet on how computers cause back problems and how to avoid them such as in Ref [1].

  2. Take as many breaks as you can - Ref [1] goes into details why it is bad to sit at computers for long times which gives the typical advice to take a break at least every 20 minutes. If I can get away with it I actually prefer to spread my day out and do some activity or exercise in between. I also get up and walk around when the computer is doing things like loading, etc. I generally try to spend as little time as possible at computers so it is good idea to plan out what you are going on a computer so you can minmise your time on them. Long times on computers or looking at other bright screens such as smart phones can also give other problems such as headaches and migraines which I have also personally experienced, so it is good idea to minmise your time on all electronic computer type devices such smart phones, tablets, etc. You can also imagine sitting hunched over on a smart phone or tablet is doing your back and neck a lot of damage.

  3. Things take longer on computer than they are suppose to - Nothing ever takes 5 minutes on a computer just waiting for them to load up takes that long, things like smart phones and tablets can be quicker but its always the case with computer type devices time seems to be eaten up quite quickly. The shortest time I ever managed on a computer is half an hour, with something like a smart phones this can reduce to 10 to 15 minutes for very simple tasks. Realistically I always allow 1 hour to 2 hours to do something on a computer depending on what I hoping to do. If I can I only plan to spend 2 hours on a computer per day and 5 hours at the absolute maxmimum obivously taking breaks every 20 minutes within that time frame. And remember computers do not always makes things faster sometimes I wander if it is just slower.

  4. Keep it simple - Even simple things can get complicated on computers so try to start as simple as possible especially when programmming. Creating modules of small pieces of codes in functions makes it easy to test and find errors. Building a very complex program all at once can make it very difficult, frastrating and time consuming to find out why the program is not working. Building your program up in small pieces of code within functions can feel time consuming but its actually the fast and easy way to build a program. It is also easier to plan your time on a computer by building small pieces of code within functions and testing it as it you create them.

Now I am going to discuss each of the codes starting with Phython, then Javascript, C/C++ and MS Excel/VBA.

Phython

Phython is the one of the four codes I have used the least however I have been told it is very easy to learn compared to other codes such as C/C++, it is also used by other engineering and analysis tools such FreeCAD, Ref [2] and Paraview, Ref [3]. From what I see it is very similar in style to Visual Basic application (VBA) which is a background code used in MS Excel to create user defined functions and programs. Phython is also the recommended code for data science it also contains build in modules for a variety applications. I hope to use phython more in the future and produce more detailed articles on applying phython to solve mathematical problems. However, if you are very new to programming phython is the language to start with, it is also growing in importance so well worth learning see Ref [4] for more details.

Javascript

Javascript is apparently the most widely used program language see Ref [5] for more details. Javascript is primarily used to create interactive websites in combination with HTML and CSS. I personally find it very simlar to 'C' programming only slightly easier to use. I have used it to create online calculators and other interactive web pages. I think it is well worth learning to use as it is the first step to creating your own interactive website but it very flexible and you can use javascript create graphs and other graphics very easily. The other advantage with Javascript is you can write your code in a text file using something like notepad and run on it any computer as it uses a web browser so essentially completely free. For details on Javascript and to learn how to use it see Ref [6] and [7].

C/C++

'C' was the first program language I learned to use and the one that got me interested in programming especially when I learnt I could use it to solve complicated mathematical problems. 'C++' is an enhanced and extended version of 'C'. 'C' is generally used to write small programs while 'C++' is used to write very large programs. 'C' and 'C++' are required to be compiled unlike the other programming languages that I have described in this article. 'C++' makes use of classes which are defined data structures which are an enhanced type of data structure found in 'C'. Classes make a program language object-orientated apparently phython is also object-orientated as it has classes. However, 'C++' I believe was the first program language to use them. The big advantage of classes is it allows you to define something as what it really represents for example say you wanted to store information on different parts of a helicopter for a flight simulator. You could create a Rotor Class, Fuselage Class and a Tail Rotor Class. Then each would have different functions which you perform on them, Rotor Class could have a function called TiltRotor() to the tilt the rotor, etc. It may not be obivous how this is helpful but it is very helpful especially when building large programs like flight simulators. OpenFOAM is an open source Computional Fluid Dynamics (CFD) code which was wrote using 'C++' if you view the source code it may give you a better idea of how classes are helpful when writing large programs. I will also explain CFD and use of C++ in more detail in future articles which will may give you a better understanding of the usefulness of class structures. For details on OpenFOAM see Ref [8]. 'C/C++' is also useful for programming embedded electronics such as a PIC microcontroller so can be especially useful if you want to build your own custom electronics for UAVs. For information on 'C' see Ref [9], 'C++' was actually invented by Bjarne Stroustrup see Ref [10] for his textbook of 'C++'. Further information and help with 'C' and 'C++' can be found in Ref [6] and [7]. Free open source 'C' and 'C++' compilers that I have used are Digital Mars, Ref [11] and Bloodshed Dev C++, Ref [12]. For Digital Mars you can write your program in a text file using something like notepad and then compile at in MS-DOS command terminal using the correct command. The advantage of Digital Mars is that you can copy the compiler files onto any computer without needing adminstration rights and use them anytime therefore it is a lot more verstile and compact but not as user friendly. The Bloodshed Dev C++ is lot more user friendly and has a GUI (Grahpic User Interface) style editor making it easier to spot and find errors and the program is also compiled from the GUI.

Visual Basic

Visual Basic is the one code that I have used professionally a lot, it is very easy to use and allows you to create user defined functions or programs within MS Excel. I have also taken a look at Google Sheets and from what I can see it seems to work in a simlar way to MS Excel. Visual Basic within MS Excel is known as VBA which stands for Visual Basic Application. It also has customisable GUIs known as User Forms in MS Excel that you use with your VBA programs. However, in the future I will probably use phython where I would have used VBA. If Google Sheets has the same functionality as MS Excel I will probably use VBA within Google sheets if I need to work with large amounts of data in tables, etc. Spreadsheets are general useful for processing large data sets into graphs, etc but phython may be able to do it just as well if not better. If you are going to use VBA with MS Excel it is technically not free however if Google Sheets has the same functionality then it would free if using it with Google Sheets. I will let you know in a future article if Google Sheets can use VBA in simlar way to MS Excel.

Generally for learning to programming code I found a free app called Sololearn very helpful see Ref [7]. Sololearn has courses for a range of different programming languages, it also has code playground which can be used to create and test programs as well as quizzes to test you knowledge of what you have learnt. O ther online resources I found useful for 'C++' is Ref [13] which is good reference for using 'C++' the other is a 'C++' quiz which you may help you to write more concise and efficient 'C++' programs, see Ref [14]. I hope you found this article useful and do not forget if you have questions please let me know.

Please leave a comment on my facebook page or via email and let me know if you found this blog article useful and if you would like to see more on this topic. Most of my blog articles are on:

  1. Mathematics

  2. Helicopters

  3. VTOL UAVs (RC Helicopters)

  4. Sailing and Sailboat Design

If there is one or more of these topics that you are specifically interested in please also let me know in your comments this will help me to write blog articles that are more helpful.

References:

[1] https://healthfully.com/what-are-the-causes-of-back-pain-when-working-on-the-computer-4449222.html

[2] https://www.paraview.org

[3] https://www.freecadweb.org

[4] https://www.python.org

[5] https://www.codecademy.com/resources/blog/what-is-javascript-used-for

[6] https://www.w3schools.com/

[7] https://www.sololearn.com/learn

[8] https://www.openfoam.com

[9] C Programming: A Modern Approach by King, K. N., King, 1996, W. W. Norton & Company

[10] C++ Programming Language, Bjarne Stroustrup, 1997, 3rd Edition, Addison-Wesley Professional

[11] https://www.digitalmars.com

[12] https://www.bloodshed.net

[13] https://cplusplus.com

[14] https://cppquiz.org

Powered by MathJax

email icon Facebook

Disclaimer: Eiteog makes every effort to provide information which is as accurate as possible. Eiteog will not be responsible for any liability, loss or risk incurred as a result of the use and application of information on its website or in its products. None of the information on Eiteog's website or in its products supersedes any information contained in documents or procedures issued by relevant aviation authorities, manufacturers, flight schools or the operators of aircraft, UAVs.

For any inquires contact: [email protected] copyright © Eiteog 2022