Function tabulation is a classic math and programming problem. It consists in sequentially finding the quantity f (x) for varying values of x . The calculation results are most often displayed in a table of two rows. The first corresponds to x , the second to f (x) .
Theory
The algorithm for determining function values consists of six steps.
- The choice of the initial and final value of the argument, the number of points.
- The calculation of the step is the amount by which the argument will change.
- The argument is taken equal to the initial value.
- Function calculation.
- Increment argument by step value.
- Repeat steps 4–5 until the required number of points has been calculated.
The values set in the first step are not always selected, they can be specified by the task. In practice, a situation occurs when a range of values and a calculation step are specified. The tabulation of the function in this case does not require finding the number of points, since the condition for the termination of the calculation (paragraph 6 of the algorithm) is the equality of the argument to the given final value.
Practical example
To understand how to use the theory, an example will help. Let a quadratic function g ( x) = x 2 + 9 be given . Let's make a table of its values in the range [–2; 2], taking the number of points equal to five. From the initial data, it is easy to estimate that the calculation step should be equal to 1.
According to the algorithm, the next step is to calculate g (–2), “–2” is the initial value of the function. By sequentially increasing x by one (in programming this operation is called incrementing) and defining the function g , the function is tabulated.
x | –2 | -1 | 0 | 1 | 2 |
g (x) | thirteen | 10 | 9 | 10 | thirteen |
It’s easy to check the correctness of the calculations - you should get a parabola graph.
Software implementation
Manually compiling a function table is a long task. Calculations should be performed carefully, an error in the calculation will make the remaining values also incorrect. The solution is to transfer the task to a computer.
Below is a program for tabulating functions on the so-called "pseudo-code". To execute it, it is necessary to set the function, the initial and final value of the arguments, the number of points. In the example, f (x) = 18 * x + 5 is calculated. The result of the program is the sequentially displayed values of x , f (x) .
- Argument: = N. Value.
- Step_calculations: = (N. value - K. value) / Qty. points.
- FOR (Counter: = 0 to Number of points).
Start:
- Function: = 18 * Argument + 5.
- Argument: = N. value + Counter * Step.
- Display on the screen (Argument, Function).
The end.
The code adapts to any programming language. That is, function tabulation can be implemented in Pascal, C +, C #, and even in the VBA office programming language integrated into the MS Office package.