Updated 2017-01-23 17:59:30 by gold

Babylonian Cubic Equation Problem and eTCL demo example calculator, numerical analysis  edit

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

Babylonian Cubic Equation Problem and eTCL demo example calculator, numerical analysis

gold Here is some eTCL starter code for Babylonian Cubic Equation Problems.

Based on the Friberg discussion of tablet, the Babylonian algorithm for a cubic equation 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 tablet has a set of line by line calculations which effectively have functions for the length, front, and depth of a room constrained, multiplied, and rescaled to equal the volume of a room. Taking the length, front, and depth of a room as three constrained functions in the variable a, the product of three functions scale_constant* length(a)* front(a)* depth(a) equals 1 volume unit. For restating the problem in a computer algorithm, the room dimensions will be each in cubits and the volume unit will be in volume sars, 1 volume sar = 144 cubic cubits. In the original problem, the room dimensions were given as 3 different length units and seems unnecessarily complicated. Once the problem is set up, the Babylonians had a lookup table for n*n*(n-1) to solve for the variable a. The eTCL calculator will have to use an iterative solution for the n*n*(n-1) series. The solution from the tablet was length 6, front 4, depth 6, and volume 144 cubits.

Some fragmented Babylonian tables known as n*n*(n+1) tables were used in solving some cubic equations, ref Joran Friberg. The equations were of the form n*n*(b*n+1) = c. The eTCL calculator could generate the expected tables of n*n*(n+1).

Other Babylonian tables known as n*(n + 1)*(n + 2) and n*n*(n – 1) tables have been identified, but no abundant use has been cited from the known Babylonian math problems. Although not clear, tables of the n*(n + 1) might have existed. From modern theory, n · (n + 1)/2 = sum of integers (1,2,3,4...) and n*(n + 1)*(n + 2) /6 = sum of squares (1,4,9....). Possibly, the Seleucid math problem used an n*(n + 1)*(n + 2) table. Possibly, the tables for n*(n + 1)*(n + 2) and n*n*(n – 1) could have been used for cubic equations.

The Seleucid method for sum of squares can be factored for sum of integers term and can be restated as a quasi_cube, ((1/3)(1+2 *n) ) * ( n(n+1)/2.) = (1/6)* n(n+1)(2n+1) = (1/6)*quasi_cube term. Another possible form for the quasi_cube (1/6)* n(n+1)(2n+1) with 2 factored out is expression 2*(1/6)* n(n+1)(n+(1/2)) . Problems for sum of squares and sum of rectangles go far back through the Selucid and Old Babylonian math, although Old Babylonian math may not demonstrate complete knowledge.

Modern derivations for sum of integer squares are treating 3 step pyramids as assembled quasi_cube such as 3* (1, 2,9,16...n**2) = n*(n+1)*(n+1/2); (1, 2,9,16...n**2) = (1/3) (n*(n+1)*(n+1/2)). The volume of the assembled quasi-cube is product of length (n) , width (n+1), and height (n+1/2)

If the quasi-cube n*(n + 1)*(n + 2) is treated as the modern derivations, the volume of the quasi-cube n*(n + 1)*(n + 2) is product of length (n) , width (n+1), and height (n+2). Then 3*expression = n*(n+1)*(n+2); expression = (1/3)*n*(n+1)*(n+2) . If the eTCL calculator is loaded for testcase 4 with depth n+2 at the window and front n+1 in the internal code, there is a solution at l*f*d of 6*5*7 =209 cubic cubits. Kind of a circular argument, but one problem VAT 6599 # 23 from Friberg has solution of l*f*d of 6*6*7 = 252 cc. If the depth of the cellar problem is modeled as (n+2), then the depth should be deeper than the normal (n+1) constraint. Using proportions, depth of 6*((n+2)/(n+1)), 6*((6+2)/(6+1)) = 6.857 cubits, close. Using proportions, front of 6*((n+1)/(n+2)), 6*((6+1)/(6+2)) = 5.25 cubits. Maybe, the problems with extended cellars (usually deeper by 1 cubit) are tracking with quasi-cube n*(n + 1)*(n + 2). Some proportional scheme or gaming with crt(volume)*((n+2)/(n+1)) or crt(volume)*((n+1)/(n+2)) is also possible. The Babylonian solutions on the tablets are effectively integer cubits, not the digital cubits the eTCL calculator throws out.

The Babylonians did not have modern algebra notation, general notation for negative numbers, or a general solution to cubic equations. In the available problem translations, there are several mathematical techniques which were used to handle cubic problems or problems in three dimensions. The documented techniques are 1) finding coefficients or functions of the three dimensions, usually a constant times length, 2) scaling technique to reduce coefficient to unity, 3) substitution and resetting dimensions, including table look up.

Pseudocode for Babylonian style method in eTCL calculator

    # using  pseudocode for Babylonian style methods and  table lookup (eg. cubic problems )
    # possible problem instances include separate tables for  cubes n*n*n and quasi_cubes
    quasi_cube n*n*(n-1), quasi_cube n*(n + 1)*(n + 2),
    quasi_cube  n*n*(n + 1), quasi_square n*(n+1)
    cube proportions of  length : front : depth  could be set like 
    1:1:1, 1:(1/2):1, 1:(2/3):1 4:(1/4):1,
    testcase 1 has l/f/h as 1*a:(2/3)*a:(12*a+1)
    testcase 1 has quasi_cube n*n*(n - 1) as model 
    depth = front ; length = depth ; cube_volume = 216
    length(1*a)*front(1*a)*depth(1*a) =216 cubic cubits
    set   table_look_up =  cube root  216
    set   table_look_up =  [** 216 [/ 1. 3. ]]  =  [** $cube_volume  [/ 1. 3. ]]
    set a $table_look_up ;
    if {quasi_cubes } { find iterative [* $n $n [- $n 1. ]] };
    set length  [* 1. $a ]  ;  set front  [* 1. $a ]     ; set  depth  [* 1. $a ]
    set check_answer  $length*$front*$depth  =?  cube_volume  (yes/no?)
    # using  pseudocode for quasi_cube n*(n + 1)*(n + 2), with Babylonian style methods. 
    set cube_root [expr 252**(1./3.) ] #=  6.3163
    set n [int [expr $volume**(1./3.) ]]   #=  6
    set factor_front [expr 6.3163*((6.3163+1.)/(6.3163+2.)) ] #= 5.5567
    set factor_depth [expr 6.3163*((6.3163+2.)/(6.3163+1.)) ] #= 7.1796
    set check_product [* 6.3163 5.5567 7.1796 ] #=251.9880
    set factor_front [expr $ n*(($n+1.)/$n+2.)) 
    set factor_depth [expr $n *(($n+2.)/($n+1.)) 
    set quasi_cube [expr $n*($n + 1.)*($n + 2.) ] #=  n= 6.3163, quasi_cube=384.3124
    set integer  [expr $n*($n + 1.)*($n + 2.) ]   #= n= 6,      quasi_cube=336.0
    set check_answer  [* [round 6.3163 ] [round 5.5567] [round 7.1796 ]]
    #= gives check_answer of 252
    integer solution would be  l/f/d = 6/5/7 cubits, [* 6 5 7 ]= 210

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
1.0 :length cubits
0.666 :front cubits
0.832 :depth cubits
1.0 :depth 2nd term cubits
144.0 :volume cubic cubits:
180 :volume limit table look up:
6 :table look up solution:
143.808 :check; product length*front*depth =? vol :
6.0 :length cubits
3.996 :front cubits
5.997 :depth cubits

Testcase 2

table 2printed in tcl wiki format
quantity value comment, if any
2:testcase_number
1.0 :length cubits
0.666 :front cubits
0.8329 :depth cubits
1.0 :depth 2nd term cubits
200.0 :volume cubic cubits:
294 :volume limit table look up:
7 :table look up solution:
222.922 :check; product length*front*depth =? vol :
7.0 :length cubits
4.6619 :front cubits
6.8309 :depth cubits

Testcase 3

table 3printed in tcl wiki format
quantity value comment, if any
3:testcase_number
1.0 :length cubits
0.666 :front cubits
0.8329 :depth cubits
1.0 :depth 2nd term cubits
300.0 :volume cubic cubits:
448 :volume limit table look up:
8 :table look up solution:
326.670 :check; product length*front*depth =? vol :
8.0 :length cubits
5.328 :front cubits
7.6639 :depth cubits

Testcase 4

table 4printed in tcl wiki format
quantity value comment, if any
4:testcase_number
1.0 :length cubits
0.666 :front cubits (n+1) increase from normal code
0.8329 :depth cubits
2.0 :depth 2nd term cubits (n+2) increase from normal value
144.0 :volume cubic cubits:
180 :volume limit table look up:
6 :table look up solution:
209.772 :check; product length*front*depth =? vol :
6.0 :length cubits
4.996 :front cubits
6.997 :depth cubits (n+2) proportional increase from normal


Screenshots Section

figure 1.


References:

  • Oneliner's Pie in the Sky
  • One Liners
  • Category Algorithm
  • Brahmagupta Area of Cyclic Quadrilateral and eTCL demo example calculator
  • Gauss Approximate Number of Primes and eTCL demo example calculator
  • goggle "Babylonian Number cuneiform Series"
  • Oneliner's Pie in the Sky
  • One Liners
  • google < Babylonian Interest Rates Wikipedia >
  • Ancient Babylonian Algorithms, Donald E. Knuth, Stanford University
  • The oldest example of compound interest in Sumer, seventh power of four thirds (4/3)**7 , Kazuo MUROI
  • Interest, Price, and Profit: An Overview of Mathematical Economics in YBC 46981,
  • Robert Middeke-Conlin Christine Proust, CNRS and Université Paris Diderot
  • Compound Interest Doubling Time Rule: Extensions and Examples from Antiquities,
  • Saad Taha Bakir, ISSN: 2241 - 1968 (print), 2241 – 195X (online)
  • Two Sumerian Words of Fractions in Babylonian Mathematics: igi-n-gál and igi-te-en , Kazuo MUROI
  • O. Neugebauer and A. Sachs, Mathematical Cuneiform Texts, American Oriental Society, Series 29. New Haven, 1945.
  • K. Muroi, Interest Calculation in Babylonian Mathematics:
  • New Interpretations of VAT 8521 and VAT 8528, Historia Scientiarum, 39, (1990), 29-34
  • O. Nuegebauer, The Exact Sciences in Antiquity, Second edition, Dover Publication Inc., New York, 1969
  • Mathematical Treasure: Old Babylonian Area Calculation, uses ancient method
  • Frank J. Swetz , Pennsylvania State University
  • Wikipedia, see temple of Edfu, area method used as late as 200 BC in Egypt.
  • Hoyrup, Jens (1992), "The Babylonian Cellar Text BM 85200 + VAT 6599 Retranslation and Analysis"
  • Square Root , Keith Vetter
  • A little slide-rule
  • What if you do not have exp()?
  • Category Algorithm
  • A Remarkable Collection of Babylonian Mathematical Texts, Joran Friberg, 2007
  • Chalmers University of Technology Gothenburg, Sweden
  • Babylonian Mathematics, cubic equations, Don Allen, Texas A&M University
  • Minna Burgess Connor, A historical survey of methods of solving cubic equations, master's thesis, 7-1-1956
  • Crossley, John; W.-C. Lun, Anthony (1999). The Nine Chapters on the Mathematical Art: Companion and Commentary. Oxford University Press.
  * Land surveying in ancient Mesopotamia, M. A. R. Cooper

Appendix Code edit

appendix TCL programs and scripts

        # pretty print from autoindent and ased editor
        # Babylonian Cubic Equation 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 {{} { length f(a) cubits : a*1 } }
        lappend names { front f(a) cubits :  a*(2/3)}
        lappend names { depth f(a) cubits :  a*12+1 : }
        lappend names { depth f(a), 2nd term cubits :  a*12+1 : }
        lappend names { volume cubic cubits:}
        lappend names {answers: length : }
        lappend names {front : }
        lappend names {depth :} 
        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 Cubic Equation Algorithm 
            from TCL WIKI,
            written on eTCL "
            tk_messageBox -title "About" -message $msg } 
        proc table_look_up {limit } {
             global look_up_function counter
             set counter 1
             while { $counter < 50.  } {
             set look_up_function [* $counter $counter [- $counter 1] ]
             if { [* $counter $counter [- $counter 1] ]   > [* $limit] } {return $counter ; break}            
             incr counter   
             }  
             }
       proc calculate {     } {
            global answer2
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global look_up_function counter check_product_lfd 
            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. ]
            # initialize hard wired solution
            set a 6.
            set room_volume $side5
            set a [ table_look_up $room_volume ]
            set room_volume [expr  ($a*$side1)*($a*$side2)*($a*$side3+$side4) ]
            set length [expr  $a*$side1 ]
            set front [expr   $a*$side2 ]
            set depth [expr   $a*$side3+$side4 ]
            set check_product_lfd [* $length $front $depth 1. ]
            set side6 $length
            set side7 $front
            set side8 $depth
             }
        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 look_up_function counter check_product_lfd
            global testcase_number
            console show;
            puts "%|table $testcase_number|printed in| tcl wiki format|% "
            puts "&| quantity| value| comment, if any|& "
            puts "&| $testcase_number:|testcase_number | |&"
            puts "&| $side1 :|length cubits|   |&"
            puts "&| $side2 :|front cubits   | |& "  
            puts "&| $side3 :|depth cubits | |& "
            puts "&| $side4 :|depth 2nd term  cubits | |&"
            puts "&| $side5 :|volume cubic cubits:  | |&"
            puts "&| $look_up_function :|volume limit table look up:  | |&"
            puts "&| $counter :|table look up solution:  | |&"
            puts "&| $check_product_lfd :|check; product length*front*depth =? vol :  | |&"
            puts "&| $side6 :|length cubits |  |&"
            puts "&| $side7 :|front cubits |  |&"
            puts "&| $side8 :|depth cubits |  |&" 
            }
        frame .buttons -bg aquamarine4
        ::ttk::button .calculator -text "Solve" -command { calculate   }
        ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 1.0 0.666  0.833 1.   144.0  6. 4. 6.}
        ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 1.0 0.666  0.833 1.0  200.0  7. 4.6 6.8 }
        ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 1.0 0.666  0.833 1.0  300.0  8. 5.3 7.6 }
        ::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 Cubic Equation 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   |&"  

One Liner Procedures for Decimal Equivalent to some Babylonian tables edit

    #   following one liners are decimal equivalent to some Babylonian tables
    #   possible cubic problem instances include separate tables for  cubes n*n*n and quasi_cubes
    #   quasi_cube n*n*(n-1), quasi_cube n*(n + 1)*(n + 2), quasi_cube  n*n*(n + 1), quasi_square n*(n+1)   
    #   list_integers is list of positive integers, 1 2 3 4 ... n
    proc list_integers { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [*  $i  1.]};return $boo}  
    # usage, list_integers 1 10
    # 1.0  1.0 2.0 2.0 3.0 3.0 4.0 4.0 5.0 5.0 6.0 6.0 7.0 7.0 8.0 8.0 9.0 9.0 10.0 10.0
    #  list_reciprocals is list of 1/1 +1/2 1/3 1/4 ... 1/n
    proc list_reciprocals { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [/  1. $i  ]};return $boo}
    # usage, list_reciprocals 1 10    
    # 1.0 1.0 2.0 0.5 3.0 0.333 4.0 0.25 5.0 0.2 6.0 0.166 7.0 0.142 8.0 0.125 9.0 0.11 10.0 0.1
    # list_squares is list of integer squares, 
    proc list_squares { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [*  $i  $i  ]};return $boo}
    # usage, list_squares 1 10  
    # 1.0 1 2.0 4 3.0 9 4.0 16 5.0 25 6.0 36 7.0 49 8.0 64 9.0 81 10.0 100
    # quasi_cube2 is n*(n)*(n-1)
    proc list_quasi_cube2 { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [*  $i  $i [- $i 1]]};return $boo}
    # usage, list_quasi_cube2  1 10   
    # 1.0 0 2.0 4 3.0 18 4.0 48 5.0 100 6.0 180 7.0 294 8.0 448 9.0 648 10.0 900
    # quasi_cube3 is n*(n+1)*(n+2)
    proc list_quasi_cube3 { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [*  $i  [+ $i 1] [+ $i 2]]};return $boo}
    # usage list_quasi_cube3   1 10
    # 1.0 6 2.0 24 3.0 60 4.0 120 5.0 210 6.0 336 7.0 504 8.0 720 9.0 990 10.0 1320
    # quasi_cube4 is n*(n)*(n+1)
    proc list_quasi_cube4 { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [*  $i  $i [+ $i 1]]};return $boo}
    # usage, list_quasi_cube4 1 10
    # 1.0 2 2.0 12 3.0 36 4.0 80 5.0 150 6.0 252 7.0 392 8.0 576 9.0 810 10.0 1100
    # quasi_square2 is  n*(n+1), 
    proc list_quasi_square2 { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [*  $i  [+ $i 1]]};return $boo}
    # usage, list_quasi_square2 1 10
    # 1.0 2 2.0 6 3.0 12 4.0 20 5.0 30 6.0 42 7.0 56 8.0 72 9.0 90 10.0 110
    # list_sum_integers 
    proc list_sum_integers { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [/  [*  $i  [+ $i 1] ] 2. ]};return $boo}
    # usage, list_sum_integers 1 10
    #1.0 1.0 2.0 3.0 3.0 6.0 4.0 10.0 5.0 15.0 6.0 21.0 7.0 28.0 8.0 36.0 9.0 45.0 10.0 55.0
    # list_sum_squares 
    proc list_sum_squares { aa bb} { for {set i 1} {$i<=$bb} {incr i} {lappend boo [* 1. $i ] [/ [*  $i  [+ $i 1.] [+ [* $i 2.]  1.]] 6.]};return $boo}
    # usage list_sum_squares 1 10
    # 1.0 1.0 2.0 5.0 3.0 14.0 4.0 30.0 5.0 55.0 6.0 91.0 7.0 140.0 8.0 204.0 9.0 285.0 10.0 385.0

Console Program for Square Root, based on Newton's method from Square Root edit

                  # autoindent from ased editor
                  # console program for babylonian algorithm for roots.
                  # combined tablet formulas and Newton's method
                  # written on Windows XP on eTCL
                  # working under TCL version 8.5.6 and eTCL 1.0.1
                  # TCL WIKI , 12dec2016             
             console show
             package require math::numtheory
             namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory }
             set tcl_precision 17
         proc square_root_function { number_for_root  } {   
             set counter 0
             set epsilon .0001
             while { $counter < 50.  } {
             if { [* $counter $counter 1. ]   > [* $number_for_root 1.] } {break}            
             incr counter 
             }   
             set  square_root_estimate $counter
             while {1} {
             set keeper $square_root_estimate        
             set starter $square_root_estimate
             set remainder   [* $starter $starter  1. ]  
             set remainder [- $number_for_root [* $starter $starter  1. ] ]
             set  square_root_estimate  [+ $starter [/ $remainder [* 2. $starter ]]]
             if {abs($keeper - $square_root_estimate) < $epsilon} break
                   }
             return $square_root_estimate
                }
             puts " square root of 2 is >>  [square_root_function 2 ] "

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

Comments Section edit

Please place any comments here, Thanks.