Adding
half the shorter leg to the longer leg of a right triangle does give a pretty good
approximation of the hypotenuse of a right triangle but it is always an overestimate.
Reduce the half to a value where the maximum % error (larger or smaller) is minimized.
0.336361
based on trial-and-error in
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For longer = 1 To 10 Step 0.1
DoEvents
hyp = Sqr(1 + longer * longer)
approx = 0.336361 + longer
Text1.Text = Text1.Text & mform(longer, " #0.0000")
Text1.Text = Text1.Text & mform(hyp, " ##0.0000")
Text1.Text = Text1.Text & mform(approx, " ##0.0000")
Text1.Text = Text1.Text & mform(approx - hyp, " ##0.0000")
Text1.Text = Text1.Text & mform((approx - hyp) / hyp, " ##0.000000")
Text1.Text = Text1.Text & crlf
Next longer
Text1.Text = Text1.Text & ct & crlf & " done"
End Sub
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
where the results of this final stage are:
leg relative
ratio true approx diff error
1.0000 1.4142 1.3364 - 0.0779 - 0.055050
1.1000 1.4866 1.4364 - 0.0502 - 0.033799
1.2000 1.5620 1.5364 - 0.0257 - 0.016446
1.3000 1.6401 1.6364 - 0.0038 - 0.002293
1.4000 1.7205 1.7364 0.0159 0.009239
1.5000 1.8028 1.8364 0.0336 0.018630
1.6000 1.8868 1.9364 0.0496 0.026269
1.7000 1.9723 2.0364 0.0641 0.032476
1.8000 2.0591 2.1364 0.0772 0.037509
1.9000 2.1471 2.2364 0.0893 0.041577
2.0000 2.2361 2.3364 0.1003 0.044852
2.1000 2.3259 2.4364 0.1104 0.047473
2.2000 2.4166 2.5364 0.1198 0.049554
2.3000 2.5080 2.6364 0.1284 0.051186
2.4000 2.6000 2.7364 0.1364 0.052447
2.5000 2.6926 2.8364 0.1438 0.053398
2.6000 2.7857 2.9364 0.1507 0.054092
2.7000 2.8792 3.0364 0.1571 0.054572
2.8000 2.9732 3.1364 0.1631 0.054872
2.9000 3.0676 3.2364 0.1688 0.055024
3.0000 3.1623 3.3364 0.1741 0.055050
3.1000 3.2573 3.4364 0.1791 0.054972
3.2000 3.3526 3.5364 0.1838 0.054808
3.3000 3.4482 3.6364 0.1882 0.054572
3.4000 3.5440 3.7364 0.1924 0.054275
3.5000 3.6401 3.8364 0.1963 0.053929
3.6000 3.7363 3.9364 0.2001 0.053543
3.7000 3.8328 4.0364 0.2036 0.053123
3.8000 3.9294 4.1364 0.2070 0.052676
3.9000 4.0262 4.2364 0.2102 0.052208
4.0000 4.1231 4.3364 0.2133 0.051722
4.1000 4.2202 4.4364 0.2162 0.051223
4.2000 4.3174 4.5364 0.2190 0.050714
4.3000 4.4147 4.6364 0.2216 0.050198
4.4000 4.5122 4.7364 0.2242 0.049678
4.5000 4.6098 4.8364 0.2266 0.049154
4.6000 4.7074 4.9364 0.2289 0.048629
4.7000 4.8052 5.0364 0.2312 0.048105
4.8000 4.9031 5.1364 0.2333 0.047583
4.9000 5.0010 5.2364 0.2354 0.047063
5.0000 5.0990 5.3364 0.2373 0.046546
5.1000 5.1971 5.4364 0.2392 0.046034
5.2000 5.2953 5.5364 0.2411 0.045527
5.3000 5.3935 5.6364 0.2428 0.045026
5.4000 5.4918 5.7364 0.2445 0.044530
5.5000 5.5902 5.8364 0.2462 0.044040
5.6000 5.6886 5.9364 0.2478 0.043557
5.7000 5.7871 6.0364 0.2493 0.043080
5.8000 5.8856 6.1364 0.2508 0.042610
5.9000 5.9841 6.2364 0.2522 0.042147
6.0000 6.0828 6.3364 0.2536 0.041691
6.1000 6.1814 6.4364 0.2549 0.041242
6.2000 6.2801 6.5364 0.2562 0.040801
6.3000 6.3789 6.6364 0.2575 0.040366
6.4000 6.4777 6.7364 0.2587 0.039938
6.5000 6.5765 6.8364 0.2599 0.039518
6.6000 6.6753 6.9364 0.2610 0.039104
6.7000 6.7742 7.0364 0.2621 0.038697
6.8000 6.8731 7.1364 0.2632 0.038298
6.9000 6.9721 7.2364 0.2643 0.037905
7.0000 7.0711 7.3364 0.2653 0.037518
7.1000 7.1701 7.4364 0.2663 0.037138
7.2000 7.2691 7.5364 0.2672 0.036765
7.3000 7.3682 7.6364 0.2682 0.036398
7.4000 7.4673 7.7364 0.2691 0.036037
7.5000 7.5664 7.8364 0.2700 0.035683
7.6000 7.6655 7.9364 0.2709 0.035334
7.7000 7.7647 8.0364 0.2717 0.034992
7.8000 7.8638 8.1364 0.2725 0.034655
7.9000 7.9630 8.2364 0.2733 0.034324
8.0000 8.0623 8.3364 0.2741 0.033998
8.1000 8.1615 8.4364 0.2749 0.033678
8.2000 8.2608 8.5364 0.2756 0.033364
8.3000 8.3600 8.6364 0.2763 0.033055
8.4000 8.4593 8.7364 0.2770 0.032750
8.5000 8.5586 8.8364 0.2777 0.032451
8.6000 8.6579 8.9364 0.2784 0.032157
8.7000 8.7573 9.0364 0.2791 0.031868
8.8000 8.8566 9.1364 0.2797 0.031584
8.9000 8.9560 9.2364 0.2804 0.031304
9.0000 9.0554 9.3364 0.2810 0.031029
9.1000 9.1548 9.4364 0.2816 0.030758
9.2000 9.2542 9.5364 0.2822 0.030491
9.3000 9.3536 9.6364 0.2828 0.030229
9.4000 9.4530 9.7364 0.2833 0.029971
9.5000 9.5525 9.8364 0.2839 0.029717
9.6000 9.6519 9.9364 0.2844 0.029467
9.7000 9.7514 10.0364 0.2850 0.029222
9.8000 9.8509 10.1364 0.2855 0.028979
9.9000 9.9504 10.2364 0.2860 0.028741
10.0000 10.0499 10.3364 0.2865 0.028506
|
Posted by Charlie
on 2017-02-08 10:51:42 |