Indian Bakhshali Square Root 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 Indian Bakhshali Square Root Algorithm in calculator shell.

The Bakhshali Square Root Algorithm from palm leaves was loaded into an eTCL calculator shell. The Bakhshali Square Root Algorithm is of historical interest, but the rule is not very accurate and dependent on an initial input or guess.

For the first testcase of sqrt, the initial trial_square_root entry of 2 gave an error of percent.


Pseudocode Section

    # using  pseudocode for  procedure algorithm.
            3 quantities needed
            target number
            trial_square_root,   w.a. guess
            formula factor , usually 2 or 3
            check approx. root from square side rule with sqrt function in TCL
     ref. errorx procedure        
     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

Testcase 2

Testcase 3

Screenshots Section

figure 1.


References:


Appendix Code

appendix TCL programs and scripts

     

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 for brackets of root

                # pretty print from autoindent and ased editor
                # console program for token multiplication and square root
                # additional verbose  
                # working under TCL version 8.5.6 and eTCL 1.0.1
                # program written on Windows XP on eTCL
                # gold on TCL WIKI, 10Mar2017
                package require Tk
                package require math::numtheory
                namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory }
                set tcl_precision 17
                console show
             global keeper target_number keep_under
             set keeper 0
             proc square_root_functionx { number_for_root  } {  
             global keeper target_number keep_under
             set counter 0
             set epsilon .0001
             while { $counter < 1000.  } {
             set keeper [* $counter $counter 1. ] 
             set target_number $number_for_root
             if { [* $counter $counter 1. ]   > [* $number_for_root 1.] } {break}  
             set keep_under $counter         
             incr counter 
             }   
             return $counter}
            puts " function gives [ square_root_functionx 10. ] ,  root for $target_number between $keep_under and  [ square_root_functionx 10. ] , max square $keeper "
            #returns positive integers under and over root.
            # function gives 4 ,  root for 10. between 3 and  4 , max square 16.0 

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

Comments Section

Please place any comments here, Thanks.