Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Sine, cosine?
Posted:
Aug 17, 1999 3:52 PM
|
|
Steve Leibel wrote:
> One key difference between the word "function" as used in math and > programming is that in math, a function is an association of x with f(x). > In programming, you must specify the algorithm for obtaining f(x) from x.
I don't see the difference. I.e. I don't think there's a fundamental one : in mathematics as well as in programming you have to 'specify' your function. Be it by tabular methods , be it by series expansion , be it by another mathematical expression ...
> Most mathematical functions could never be programmed, becase there are > more functions than algorithms.
Is this true ? According to above , I would say it isn't. Of course I take now abstraction of the feasibility to calculate it with sufficient accuracy in reasonable time.
> > > Secondly, a function in a programming language may have global side > effects, and often the "return" value is just a status or error code. To
Exposed to the wrong programming language , I'm afraid.Functions with global side effects are in a lot of developped countries forbidden by law.
> use a very well-known example, printf() writes characters on a console,
A decent language calls a beast like printf() not a _function_ but a procedure.
> and returns an integer giving the number of characters written. I doubt > that one C programmer in a thousand checks or uses the return value from > printf(); and I doubt that one in a hundred even knows printf() returns a > value. > > If a mathematical function were like a programming function, when you took > the cosine of pi it would not only give you the answer, it would also turn > on your television.
You make your comparison the wrong direction. A well developped programming function acts like a mathematical function.
> > > In my opinion the use of the word "function" in programming is just a > loose adaptation of the mathematical word, and has no significance beyond > that. > > There is simply no similarity between a mathematical function defined as a > particular subset of the cartesian product of two sets, and the usage in > programming to mean a little bundle of code that executes an algorithm, > manipulates its environment, and returns a value that is often not even > regarded as important. > > Steve L
|
|
|
|