Skip to main content

Array Computing and Curve Plotting

  • Chapter
  • 14k Accesses

Part of the book series: Texts in Computational Science and Engineering ((TCSE,volume 6))

Abstract

Arrays represent perhaps the most useful object in numerical computing. This chapter gives a brief introduction to arrays, how they are created and what they can be used for. Array computing usually ends up with a lot of numbers, which are hard to understand unless they are visualized in a proper way. This chapter concentrates on visualizing one-dimensional array data as curves of the form y=f(x). We describe Python tools for plotting such curves.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   59.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    Many may argue that programmers of mathematical software have traditionally paid too much attention to efficiency and smart program constructs. The resulting software often becomes very hard to maintain and extend. In this book we advocate a focus on clear, well-designed, and easy-to-understand programs that work correctly. Optimization for speed should always come as a second step in program development.

  2. 2.

    A car is of course not a mathematical point, but when studying the acceleration of a car, it suffices to view it as a point. In other occasions, e.g., when simulating a car crash on a computer, the car may be modeled by a large number (say 106) of connected points.

  3. 3.

    You might recall many of the formulas here from high school mathematics or physics. The really new thing in this chapter is that we show how rules for vectors in the plane and in space can easily be extended to vectors in n-dimensional space.

  4. 4.

    From high school mathematics and physics you might recall that the inner or dot product also can be expressed as the product of the lengths of the two vectors multiplied by the cosine of the angle between them. We will not make use of this formula.

  5. 5.

    The number of elements can be changed, at a substantial computational cost.

  6. 6.

    Actually, there is an object type called array in standard Python, but this data type is not so efficient for mathematical computations.

  7. 7.

    This is referred to as allocating the array, and means that a part of the computer’s memory is marked for being occupied by this array.

  8. 8.

    In general, the Python syntax used in the examples in this book is constructed to ease the transition to and from Matlab.

  9. 9.

    See the heading “Setting Parameters in the Configuration File” in the Easyviz documentation.

  10. 10.

    Python and many other languages use the word directory instead of folder. Consequently, the name of functions dealing with folders have a name with dir for “directory”.

  11. 11.

    Recall that and and or are reserved keywords, see page 10, so a module or program cannot have variables or functions with these names. To circumvent this problem, the convention is to add a trailing underscore to the name.

  12. 12.

    MacBook Air 11”, 1.6 GHz Intel CPU, running Ubuntu in a VMWare virtual machine.

  13. 13.

    Mathematicians don’t like this sentence, but it suffices for our purposes.

  14. 14.

    This is the way the array elements are stored in the computer’s memory.

  15. 15.

    Note that it is very important to use consistent units. Here we express all units in terms of meter, second, and Kelvin or Celsius.

  16. 16.

    Here we assume that the temperature T equals the reference temperature T 0 at t=0, resulting in a sine variation rather than the cosine variation in (5.13).

  17. 17.

    This layer is called a boundary layer. The physics in the boundary layer is very important for air resistance and cooling/heating of objects.

References

  1. H. P. Langtangen. Python Scripting for Computational Science, volume 3 of Texts in Computational Science and Engineering. Springer, Berlin, 3rd edition, 2009.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Langtangen, H.P. (2012). Array Computing and Curve Plotting. In: A Primer on Scientific Programming with Python. Texts in Computational Science and Engineering, vol 6. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-30293-0_5

Download citation

Publish with us

Policies and ethics