About generation of number sequences in SQL Server page 2 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
B. About Fibonacci sequenceThe Fibonacci sequence might be calculated by this iteration formula: A[i+2] = A[i] + A[i+1]; i = 1,…, n; A[1] = A[2] = 1. It`s simple to see the analogy with general case in previous point if we bring in function f(x,y)=x+y. The [iter] column is used for keeping iteration`s number, [a] column is used for keeping A[i], [b] and [c] for A[i+1] and A[i+2] correspondingly. The [d] column is not in use. The calculation of Fibonacci numbers may be put into code accordingly to general method like this:
Let`s give the result of query for calculation Fibonacci numbers are less than 1000 (2nd column).
C. Equation`s root findingThe large section of mathematical and functional analysis is dedicated to finding equations` roots of one-variable and multivariable functions. The root of equation g(x) = 0 is a number r (or vector r) which complies with condition g(r) = 0. The general method of solving such equations is in reduction to the problem of fixed point: x=f(x). The sense of this reduction is in the finding of such function f which makes equations g(x) = 0 and x = f(x) equivalent. Besides, operator f must be contracting. That is if the value r1 takes place near solution r, than the value r2 = f(r1) must be even nearer to the solution: abs(r-r2) < A * abs(r-r1), where positive constant A is less then unity (A<1) and isn`t depends on select of r1 value. The contracting mappings are possible be many. The preference ones are that for which A constant takes less value. The less the constant the process of finding of equation`s g(x) root converges faster: r2 = f(r1), r3 = f(r2), r4 = f(r3) …Let`s note an illustrating example in SQL. |