Babylonian Field Expansion Procedure Algorithm and eTCL demo example calculator, numerical analysis

This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER in your comment with the same courtesy that I will give you. Its very hard to reply intelligibly without some background of the correspondent. Thanks,gold


gold Here is some eTCL starter code for Babylonian Field Expansion Procedure Algorithm in calculator shell. Additional console program below is used to check or improve subroutine.

Here is some eTCL starter code for Babylonian field expansion procedure algorithm. The Babylonian field expansion procedure algorithm from clay tablets was loaded into an eTCL calculator. The Babylonians did not use algebra notation, so the reader will have to bear some anachronisms in the eTCL pseudocode. The field expansion procedure is defined as the method used by scribes to succesively reduce or add numbers or number products by integer fractions, usually 1/60, 2/60, 3/60 et al. In modern terms, the numbers in base 60 that appeared on the tablet would be n+(1/60), n+(2/60), n+(3/60) until a desired goal for is reached. On some clay tablets to reach a desired field area of 100 square units called a iku (Akkadian for field), the succesive altered sides a*b would be (a+(1/60))*(b+(1/60)),(a2+(1/60))*(b2+(1/60))...until (a_f+(1/60))*(n_f+(1/60)) ~= 100. Allowing for some number rounding, the field expansion procedure would produce an almost square field of 100 square units. The inherent error should be less than 1/60, error <= (/ 1. 60.). The field expansion procedure can be extended to produce rectanglar fields of certain desired areas or side a/b ratios. The bare numbers on the tablets were not usually marked with units or annotated. Succesive or iterated math solutions are called algorithms and the field expansion procedure is one of the earliest algorithms documented. The TCL procedures are descendants of this idea. For restating the problem in a computer algorithm, the sides and field area will be in meters and square meters, respectively.

The reason for the field expansion procedure is not completely understood. However, there are some peg points or analogies available. The early examples of the field expansion procedure are from clay tablets of the proto-literate mathematical texts around 3000 BCE and metro-mathematical school texts from the Early Sumerian Dynastic III Period around 2500 BCE, ref Friberg. The successive addition and clay marks/counterpieces look somewhat like the pebble math problems, pebble games, or penny problems of some later cultures. Possibly, the concern with sides of 10 units and area of 100 square units may be a separate or earlier tradition than base sixty. For example, one would think that side of 12 units and area of 144 square units would track better with base 60. The almost square fields or concern with squares in some problems suggest the field expansion procedure was a method that avoided square roots or predated taking square roots. The cuneiform methods for taking areas of squares and rectangles were accurate, a*a or a*b. In those eras, the common approximate quadrilateral formula for area (a+c)*(b+d)*.25 was very inaccurate, inconsistent, and lead to unfair tax assessments. Taxes or interest were 1/60 per month or 12/60 per year of the harvest in some eras, so an accurate survey would almost pay the years taxes. There probably was some motivation to extend an accurate confirmed square area into an accurate rectanglar field vis using the inconsistent approximate quadrilateral formula. The Babylonian false position algorithm on this wiki does take a square root and may be a later development.


Pseudocode Section

    # using  pseudocode for Babylonian  field expansion procedure algorithm. 
    # possible problem instances include add 1/60 to sides until area goal reached
     long_side = supplied value
     short_side  =  supplied value
     desired_goal  =  supplied value 
    # desired_goal usually 100 square units in some early math problems
     set old_field_area = a*b ,  old field_area = long_side * short_side  
     set new_side_a = long_side + 1/60
     set new_side_b = short_side + 1/60
     set new_field_area = (long_side + 1/60) * ( short_side + 1/60 )
     is  new_field_area =? desired_area within +/- (1/60) , yes = finished loop
     check error , abs (desired_goal -  new_field_area) <= [/ 1. 60.] 
     half area =  area  * .5
     quarter area = area * .25
     check_answer   new area =? desired goal , desired goal reached (yes/no)
     set answers and printout with resulting values

Testcases Section

In planning any software, it is advisable to gather a number of testcases to check the results of the program. The math for the testcases can be checked by pasting statements in the TCL console. Aside from the TCL calculator display, when one presses the report button on the calculator, one will have console show access to the capacity functions (subroutines).

Testcase 1

table 1printed in tcl wiki format
quantity value comment, if any
1:testcase_number
10.2 :long side meters
9.5 :short side meters
100.0 :desired area (usually 1 iku, 100 square units)
96.899 :answers: old area meters squared
0.166 :area lacking meters squared
100.211 :area from new sides meters squared
10.366 :long side meters
9.666 :short side meters

Testcase 2

table 2printed in tcl wiki format
quantity value comment, if any
2:testcase_number
9.599 :long side meters
9.060 :short side meters
100.0 :desired area (usually 1 iku, 100 square units)
86.975 :answers: old area meters squared
0.683 :area lacking meters squared
100.193 :area from new sides meters squared
10.283 :long side meters
9.743 :short side meters

Testcase 3

table 3printed in tcl wiki format
quantity value comment, if any
3:testcase_number
9.5 :long side meters
9.0 :short side meters
100.0 :desired area (usually 1 iku, 100 square units)
85.5 :answers: old area meters squared
0.7666 :area lacking meters squared
100.271 :area from new sides meters squared
10.266 :long side meters
9.766 :short side meters

Screenshots Section

figure 1.

Babylonian Field Expansion Procedure Algorithm and eTCL demo example calculator screenshot


References:

September 2009


Appendix Code

appendix TCL programs and scripts

        # pretty print from autoindent and ased editor
        # Babylonian Field Expansion Procedure Algorithm calculator
        # written on Windows XP on eTCL
        # working under TCL version 8.5.6 and eTCL 1.0.1
        # gold on TCL WIKI, 15jan2017
        package require Tk
        package require math::numtheory
        namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory }
        set tcl_precision 17
        frame .frame -relief flat -bg aquamarine4
        pack .frame -side top -fill y -anchor center
        set names {{} { long side meters :} }
        lappend names { short side meters :}
        lappend names { desired area (usually 1 iku, 100 square units) : }
        lappend names { answers: old area meters squared : }
        lappend names { area lacking meters squared :}
        lappend names { area from new sides  meters squared: }
        lappend names { long side meters : }
        lappend names { short side meters :} 
        foreach i {1 2 3 4 5 6 7 8} {
            label .frame.label$i -text [lindex $names $i] -anchor e
            entry .frame.entry$i -width 35 -textvariable side$i
            grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 }
        proc about {} {
            set msg "Calculator for Babylonian Field Expansion Procedure Algorithm 
            from TCL WIKI,
            written on eTCL "
            tk_messageBox -title "About" -message $msg } 
       proc calculate {     } {
            global answer2
            global side1 side2 side3 side4 side5
            global side6 side7 side8 
            global testcase_number 
            incr testcase_number 
            set side1 [* $side1 1. ]
            set side2 [* $side2 1. ]
            set side3 [* $side3 1. ]
            set side4 [* $side4 1. ]
            set side5 [* $side5 1. ]
            set side6 [* $side6 1. ]
            set side7 [* $side7 1. ]
            set side8 [* $side8 1. ] 
            set true_area [* $side1 $side2 ]
            set desired_area $side3
            # initialize ancient correction fraction
            set correction_fraction [/  1. 60. ]
            set correction_fraction [* [/ [- $desired_area $true_area] $desired_area ] 5. ]
             set counter 1
             while { $counter < 50.  } {
             if { [* [+ $side1 [/ $counter 60. ]] [+ $side2 [/ $counter 60. ]]  ]  > $desired_area } {; break}           
             incr counter   
             }  
            set correction_fraction [/  $counter 60. ]
            set side4 $true_area
            set side5 $correction_fraction
            set side6 [* [+ $side1 $correction_fraction ] [+ $side2 $correction_fraction ]   ]
            set side7 [+ $side1 $correction_fraction ]
            set side8 [+ $side2 $correction_fraction ]  
                    }
        proc fillup {aa bb cc dd ee ff gg hh} {
            .frame.entry1 insert 0 "$aa"
            .frame.entry2 insert 0 "$bb"
            .frame.entry3 insert 0 "$cc"
            .frame.entry4 insert 0 "$dd"
            .frame.entry5 insert 0 "$ee"
            .frame.entry6 insert 0 "$ff" 
            .frame.entry7 insert 0 "$gg"
            .frame.entry8 insert 0 "$hh" 
             }
        proc clearx {} {
            foreach i {1 2 3 4 5 6 7 8 } {
                .frame.entry$i delete 0 end } }
        proc reportx {} {
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global testcase_number reference_factor flag
            console show;
            puts "%|table $testcase_number|printed in| tcl wiki format|% "
            puts "&| quantity| value| comment, if any|& "
            puts "&| $testcase_number:|testcase_number | |& "
            puts "&| $side1 :|long side meters |   |&"
            puts "&| $side2 :|short side meters | |& "  
            puts "&| $side3 :|desired area (usually 1 iku, 100 square units)| |& "
            puts "&| $side4 :|answers: old area meters squared| |&"
            puts "&| $side5 :|area lacking meters squared  | |&"
            puts "&| $side6 :|area from new sides  meters squared |  |&"
            puts "&| $side7 :|long side meters  |  |&"
            puts "&| $side8 :|short side meters |  |&" 
            }
        frame .buttons -bg aquamarine4
        ::ttk::button .calculator -text "Solve" -command { calculate   }
        ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 10.2  9.5  100.0 96.9  0.0166  100.2 10.2 9.51}
        ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 9.6  9.06 100. 86.9  .68  100.2 10.2 9.74 }
        ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 9.5  9.0  100.0 85.5  0.76  100.3  10.26 9.7 }
        ::ttk::button .clearallx -text clear -command {clearx }
        ::ttk::button .about -text about -command {about}
        ::ttk::button .cons -text report -command { reportx }
        ::ttk::button .exit -text exit -command {exit}
        pack .calculator  -in .buttons -side top -padx 10 -pady 5
        pack  .clearallx .cons .about .exit .test4 .test3 .test2   -side bottom -in .buttons
        grid .frame .buttons -sticky ns -pady {0 10}
               . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30
        wm title . "Babylonian Field Expansion Procedure Algorithm Calculator"  

Pushbutton Operation

For the push buttons, the recommended procedure is push testcase and fill frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console.

For testcases in a computer session, the eTCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers will be cleared on the next solve button. The command { calculate; reportx } or { calculate ; reportx; clearx } can be added or changed to report automatically. Another wrinkle would be to print out the current text, delimiters, and numbers in a TCL wiki style table as

  puts " %| testcase $testcase_number | value| units |comment |%"
  puts " &| volume| $volume| cubic meters |based on length $side1 and width $side2   |&"  

Console program under test.

from ASK12, need help on Field Expansion subroutine

gold - 2017-01-25 On the this tcl wiki, the code in Field Expansion calculator is working when solution approachs the answer from below the desired number, but the solution needs to approach correctly from either below or above the desired number. This routine is sort of like a double barreled newton's method from Square Root, especially proc SqrtB {num} {# Newton's method}. Wrote a test console program for a field_expansion_procedure at bottom of wiki page. Can someone help or load corrected code for the console program at bottom of page. I am drawing a mental blank. Babylonian Field Expansion Procedure Algorithm and example demo eTCL calculator, numerical analysis

                  # autoindent from ased editor
                  # console program for babylonian field_expansion_procedure.
                  # troubles updating variables below and above solution  
                  # written on Windows XP on eTCL
                  # working under TCL version 8.5.6 and eTCL 1.0.1
                  # TCL WIKI , 28jan2017
             console show
             package require math::numtheory
             namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory }
             set tcl_precision 17
             proc field_expansion_procedure_function2 { side1 side2 side3 side4 epsilon } { 
             set counter 1
             set token1 $side1
             set token2 $side2
             set epsilon [/ 1. $side4]
             while { $counter < 50.  } {
             if { [abs [- $side3 [* $token1 $token2  1. ] ] ]  < $epsilon } {break;} 
             if { [- $side3 [* $token1 $token2  1. ] ]   > 0 } {set correction_fraction [* 1. [/ 1. $side4]  ]} 
             if { [- $side3 [* $token1 $token2  1. ] ]   < 0 } {set correction_fraction [* -1. [/ 1. $side4]  ]}        
             set correction_fraction [- $side3 [* $token1 $token2  1. ] ]
             set token1 [+ $token1 $correction_fraction ]
             set token2 [+ $token2 $correction_fraction ]  
             incr counter  
             puts "token $token1 token $token2 product [* $token1 $token2 ] correction $correction_fraction"
             }   }
             set side8 [ field_expansion_procedure_function2   5. 4. 100. 60. .15   ]

gold This page is copyrighted under the TCL/TK license terms, this license .

Comments Section

Please place any comments here, Thanks.