Programming Clinic II

The programming examples here and subsequently are given to explain certain concepts on Vectors, tensors, continuum mechanics or show you how to use specific Mathematica functions. The following steps should be followed:
1. Type in the codes and ensure they run error-free.
2. Try to understand the working program so that you can use similar constructs in your own coding. Make use of the help system in Mathematica to understand other ways you may be able to invoke the same functions with other argument sets and options. Sometimes the codes involve technical issues or a deeper understanding of vectors, geometry and transformations. Do not rush over those issues. A good programmer learns to address such issues and increases in knowledge.
3. Write your own programs by modifying and adding to the code you have been given to do similar or other things.
These steps will help you become more confident on your ability to create your own codes.
Note that turning your understanding of a concept to computer program that works is one of the best ways to master concepts. There is no way to forget such things that you have turned into codes by yourself!

Download (PDF, 504KB)


Note that all the codes included in this practical class are either given in the Continuum Mechanics main text that you should have downloaded by now, or in the appropriate lecture slides.
We remind you again that the questions on the test on Friday are essentially paraphrases, in objective form, of the same examples that have been solved for you in the book. You are to further remember that you may be able to get further assistance from us by posting questions and comments on the same web page.
Please post questions ONLY after availing yourself of all the other facilities already available. In particular, do not ask questions that have been adequately answered in the book unless you specifically want further elucidation after a honest attempt at the one given in the book.

2 comments on “Programming Clinic II

  1. Adingupu Stephen says:

    Good day Sir, I have a question regarding example 6 in the mathematica code, on the line object to be precise, I understand the parameterization equation use in the parametricplot3D function as well as the index call mathematica uses what I do not understand is the values added 2, 3, 1 I assumed from the parameterization equation they come from the co-ordinates written previously but if so shouldn’t 1 come before 3?

    //line object
    l1 = ParametricPlot3D[{2 + v3[[1]] t, 3 + v3[[2]] t, 1 + v3[[3]]t }, {t, -2, 1},
    PlotStyle -> Directive[Red, Thickness[0.01]]];

    //the initializations since v1 is 2, 1, 3 shouldn’t l1 be
    v1 = {2, 1, 3}; v2 = {1, -1, 1}; v3 = Cross[v1, v2];

    //line object
    l1 = ParametricPlot3D[{2 + v3[[1]] t, 1 + v3[[2]] t, 3 + v3[[3]]t }, {t, -2, 1},
    PlotStyle -> Directive[Red, Thickness[0.01]]];

    I ran this too but the graph was different I do not understand why since the parameterization equation is x1 = x01 + au01 I assumed x0 refers to 2,1,3

    • oafak says:

      I plan to spend more time on parametrization in the Programming Clinic 3 taking place in Systems Engineering Wednesday, September 4.

Leave a Reply

Your email address will not be published. Required fields are marked *