Module 8: Lecture Notes for Math 170

Return to Lecture Notes page.
Some images on this page have been generated via AsciiMathML.js.
For more information see: www.chapman.edu/~jipsen/asciimath.html.

  1. Mathematical functions have a specific meaning. For math function, that are built-in a language, these functions generally correspond to our idea of a math function: values are sent to a function and it returns a value.
  2. Computer functions are built-in, provided in an additional library, or user-supplied.
  3. The trend today is to talk about functions as opposed to subroutines.
  4. The rules for a function in a computer language may vary to quite an extent.
  5. In general, a computer function returns a value, but this is not always the case. [Interestingly, in some languages functions return a value even if you do not tell them to do so and, at the same time, you do not need to use that value.]
  6. In computer "lingo" we often talk about arguments and parameters. Function calls have "arguments" and function definitions have parameters.
  7. Over the years we have come to "expect" that a function will not have a side-effect. That is, a function will return a value but it will not change any value sent to it or any value outside of it. This is not always the case. [An example of where this might not apply would be a sort function. We might send it a list of items and expect the sort function to return the list sorted. In some languages the belief that a function should not have side effects gives rise to having the sort function return a sorted list of values, but not change the argument list. In that situation one would call the sort function and assign its return value to the original list, if that is what you wanted to do.]
  8. There is also an expectation that a function will not need any value that is not sent to it via an argument-parameter match. This expectation, too, is not met in some situations.
  9. Care must be taken with mathematical functions to be sure that you are using the correct units. Thus, while we might understand the sin(30°) most built-in sin() functions expect the argument to be given in radians.
  10. There is no list of universally available math functions. Each computer language defines its own. Care should be taken to be sure that you understand how the language you are using defines its functions.
  11. Take the limits on the range of functions seriously. Sending a function an argument outside of that range may produce unexpected results, or even no result.

Return to Lecture Notes page.

©Roger M. Palay
Saline, MI 48176
November, 2013