Math Library Functions BY: RICHA JAIN

Functions in Mathematics “A relationship between two variables, typically xand y, is called a function, if there is a rulethat assigns to each value of xone and only one value of y.”So, for example, if we have a function f(x) = x+ 1 then we know that f(-2.5) = -2.5 + 1 = -1.5 f(-2) = -2 + 1 = -1 f(-1) = -1 + 1 = 0 f(0) = 0 + 1 = +1 f(+1) = +1 + 1 = +2 f(+2) = +2 + 1 = +3 f(+2.5) = +2.5 + 1 = +3.5 …

Functions in Mathematics Likewise, if we have a function a(y) = | y| then we know that …a(-2.5) = | -2.5 | = +2.5 a(-2) = | -2 | = +2 a(-1) = | -1 | = +1 a(0) = | 0 | = 0 a(+1) = | +1 | = +1 a(+2) = | +2 | = +2 a(+2.5) = | +2.5 | = +2.5 …

Function Argument f(x) = x+ 1 a(y) = | y| We refer to the thing inside the parentheses immediately after the name of the function as the argument(also known as the parameter) of the function. In the examples above: •the argument of the function named fis x; •the argument of the function named ais y.

Absolute Value Function in C •The absfunction calculates the absolute valueof its argument. It’sthe C analogue of the mathematical function a(y) = | y| (the absolute value function) a= abs(y);

Absolute Value Function in C …fabs(-2.5) returns 2.5 abs(-2) returns 2 abs(-1) returns 1 abs(0) returns 0 abs(1) returns 1 abs(2) returns 2 fabs(2.5) returns 2.5 …

Absolute Value Function in C #3 We say “absof -2 evaluates to2” or “absof -2 returns2.”Note that the function named abscalculates the absolute value of an intargument, and fabscalculates the absolute value of a floatargument.

Function Call in Programming

#### You've reached the end of your free preview.

Want to read all 22 pages?

- Spring '19
- C Programming, Continuous function, fabs