to illustrate I will use a system of linear equations of degree 5, this will not give us much precision but it will show the algorithm
lets approximate sqr between 1 and 2, here I will divide the interval between 0 and 1
matrix A
Code: Select all
[[1, 1/(0+1), 1/(0+2), 1/(0+3), 1/(0+4)],
[1, 1/(1/4+1), 1/(1/4+2), 1/(1/4+3), 1/(1/4+4)],
[1, 1/(2/4+1), 1/(2/4+2), 1/(2/4+3), 1/(2/4+4)],
[1, 1/(3/4+1), 1/(3/4+2), 1/(3/4+3), 1/(3/4+4)],
[1, 1/(4/4+1), 1/(4/4+2), 1/(4/4+3), 1/(4/4+4)]]
Code: Select all
[[sqr(1+0)],
[sqr(1+1/4)],
[sqr(1+2/4)],
[sqr(1+3/4)],
[sqr(1+4/4)]]
Code: Select all
Function Sqr1(Byval z As Double) As Double
Return 4.1699272354475147801+_
.14280730704570221521/(z+1.)-_
7.8444468921392051374/(z+2.)+_
41.993569124718655109/(z+3.)-_
53.553469885319331185/(z+4.)
End Function
Dim As Double y
Print " x sqrt(1+x) error"
For x As Double=0 To 1.05 Step 0.1
y=Sqr1(x)
Print Using "##.###";x;
Print " ";y, y-sqr(1+x)
Next
sleep
Code: Select all
x sqrt(1+x) error
0.000 1.000000000000002 1.776356839400251e-015
0.100 1.048791856644213 -1.699152593870323e-005
0.200 1.095439834710485 -5.2802998475876e-006
0.300 1.140178581579455 3.156480317345611e-006
0.400 1.183219503184455 3.546564532053154e-006
0.500 1.224744871391589 4.440892098500626e-016
0.600 1.264908485536255 -2.578531096864012e-006
0.700 1.303838815119589 -1.66592094119622e-006
0.800 1.341642803058836 2.016558961814852e-006
0.900 1.378409547471753 4.67226273070942e-006
1.000 1.414213562373096 6.661338147750939e-016
Code: Select all
Function Sqr1(Byval z As Double) As Double
dim as double n, m
n=24+(61.986659812467627+_
(57.111308428075295+_
(22.437732008780969+_
4.1699272354475148*z)*z)*z)*z
m=24+(50+(35+(10+z)*z)*z)*z
return n/m
End Function