***One Line Procedures Follow-up and Templates V2 and TCL 8.6 demo examples 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 and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply reasonably without some background of the correspondent on his WIKI bio page. Thanks, [gold] 20Aug2020 ---- Trial Edit ---- <> ***Preface*** [gold] 1sep2021 Here are some calculations. ---- ***Introduction*** ---- ---- ***References:*** ---- * Wikipedia search engine < diabetes insulin resistance > * Wikipedia search engine < Richard K. Bernstein > * Wikipedia search engine < Programming Examples > * Google search engine < vaporware > * [One Liners Programs Pie in the Sky] * [One Liners] * One Liners Programs Compendium [https://wiki.tcl-lang.org/page/One+Liners+Programs+Compendium++and+TCL+demo+examples+calculations%2C+numerical+analysis] * WIKI BOOKS, Programming_Examples pdf * WIKI BOOKS, Tcl_Programming_Introduction pdf ---- ***Testcases Section*** In planning any software, it is advisable to gather a number of testcases to check the results of the program. ---- **** Testcase 1, **** ---- ---- %| table 1| | printed in|TCL format |% %| homa_IR_2 units | insulin units |glucose units |comment, if any|% &| 0.81500 | 3.3000 | 100. | |& &| 0.84000 | 3.4000 | 100. | |& &| 0.86400 | 3.5000 | 100. | |& &| 0.88900 | 3.6000 | 100. | |& &| 0.91400 | 3.7000 | 100. | |& &| 0.93800 | 3.8000 | 100. | |& &| 0.96300 | 3.9000 | 100. | |& &| 0.98800 | 4.0000 | 100. | answer for testcase 1 |& &| 1.0120 | 4.1000 | 100. | |& &| 1.0370 | 4.2000 | 100. | |& ---- ---- **** Testcase 2, **** ---- Example calculation for 6 insulin and 110 glucose. Evals HOMA_IR approximates 1.63. Quicki index =~ 0.35. ---- **** Testcase 3, **** ---- Example calculation for 2 insulin and 90 glucose. Evals HOMA_IR approximates 0.44. Quicki index =~ 0.44. ---- ---- **** Testcase 4, Protocol for A1c **** ---- Protocol for A1c of 5.0 and insulin of 4. A1c of 5.0 converts to average Blood Glucose of 96.8. Example calculation for 4 insulin and 96.8 glucose evals to HOMA-IR of 0.48. Quicki index =~ 0.44 ---- ***Screenshots Section*** ---- ****figure 1. Screenshot, HOMA_IR_Average_Blood_Insulin_resistance **** ---- ---- ---- [HOMA_IR_Average_Blood_Insulin_resistance_2] ---- ***Appendix TCL programs and scripts **** *** Pretty Print Version*** ---- ====== # pretty print from autoindent and ased editor # Convert homa_IR_2 from Average Blood Glucose mg/dl V2 # Console program example demo # written on Windows 10 on TCL # working under TCL version 8.6 # gold on TCL Club , 30aug2021 # Each homa_IR_2 reading usually from # limits of 0.4 to 11 # Roughly 5 HbA1c converts to 100 # mg/dl abbrev. for milligrams per deciliter # mmol/L abbrev. for milligrams per Liter package require Tk package require math::numtheory package require math::constants package require math::trig package require math namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants } set tclprecision 17 console show # following dresses up console output to easy eye console eval {.console config -bg palegreen} console eval {.console config -font {fixed 20 bold}} console eval {wm geometry . 40x20} set tclprecision 17 # conversion unit formulas in procs # HOMA_IR = expr { $insulin * $glucose * $scale_factor} proc HOMA_IR2 { insulin glucose } { set scale_factor [ expr { 1. / 405. } ] return [expr { $insulin * $glucose * $scale_factor}]} # hbA1c_convert_to_average_blood_glucose mg/dl HbA1c proc a1c hbA1c { expr { 35.6*$hbA1c -77.3} } # convert mg/dl to mmol/L average blood glucose # some papers round off 18.016 to mgdl/18. proc mgdl_to_mmoll mgdl { expr { $mgdl/18.0 } } # convert mmol/L to mg/dl average blood glucose proc mmoll_to_mgdl mmoll { expr { $mmoll*18.0 } } # proc precisionx used to round off floating point numbers proc precisionx {precision float} { # tcl:wiki:Floating-point formatting, # select numbers only, not used on every number. set x [ expr {round( 10 ** $precision * $float) / (10.0 ** $precision)} ] # rounded or clipped to nearest 5ird significant figure set x [ format "%#.5g" $x ] return $x } proc table_format_out n { set sum 0 # initial level set count 0.0 set glucose 100. puts "%| table| | printed in|TCL format |% " puts "%| homa_IR_2 units | insulin units |glucose units |comment, if any|% " # adapted proc from # printout in TCL WIKI format table for { set i 1 } { $i <= $n } { incr i } { set count [+ $count .1] set insulin $count set homa_IR_2 [ HOMA_IR2 $insulin $glucose ] set insulin [ precisionx 3 $insulin ] set glocose [ precisionx 3 $glucose ] puts "&| [ precisionx 3 $homa_IR_2 ] | $insulin | $glucose | |&" incr sum $i } return $sum } puts " Console wrapper for solution proc" puts " ***************************" puts " ***************************" table_format_out 90 wm title . "Homa_IR_2 V2 " # end of working deck # add cosmetics below to bottom of file console eval {.console config -bg palegreen} console eval {.console config -font {fixed 20 bold}} console eval {wm geometry . 40x20} console eval {wm title . " Report for Homa_IR_2 "} console eval {. configure -background orange -highlightcolor brown -relief raised -border 30} ====== ---- ---- *** Conversion unit formulas in one line TCL procs *** ---- ---- ====== # conversion unit formulas in one line TCL procs # HOMA-IR standing for Homeostatic Model Assessment of Insulin Resistance # HOMA_IR = expr { $insulin * $glucose * $scale_factor} # fasting blood insulin in units uIU/mL # fasting blood glucose in units mg/dL proc HOMA_IR2 { insulin glucose } { set scale_factor [ expr { 1. / 405. } ] return [expr { $insulin * $glucose * $scale_factor}]} # HOMA-IR calculations here requires U.S. standard units. # European SI units as best understood. # To convert component terms of HOMA-IR ( $insulin & $glucose) # from international S.I. units: # Insulin: pmol/L to uIU/mL, divide by (รท) 6 # Glucose: mmol/L to mg/dL, multiply by (x) 18 # hbA1c_convert_to_average_blood_glucose mg/dl HbA1c # HbA1c test is a simple blood test that measures your # average blood sugar levels over the past 3 months. # As a peg point, 5 HbA1c units converts to 100 mg/dl, # mg/dl is abbreviation for milligrams per deciliter. proc a1c hbA1c { expr { 35.6*$hbA1c -77.3} } # convert mg/dl to mmol/L average blood glucose # European SI units conversion on blood glucose # some papers round off 18.016 to mgdl/18. proc mgdl_to_mmoll mgdl { expr { $mgdl/18.0 } } # convert mmol/L to mg/dl average blood glucose proc mmoll_to_mgdl mmoll { expr { $mmoll*18.0 } } # formula QUICKI_index insulin resistance = 1/(log(insulin) + log(glucose)), decimal logs proc QUICKI_INDEX_IR { insulin glucose } { return [ expr { 1./(log10($insulin) + log10($glucose))} ] } # Usage set answer [ QUICKI_INDEX_IR 4. 100. ] # eval 0.38 ====== ---- ---- **Hidden Comments Section** <> Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Thanks, [gold] 12Aug2020 ---- ---- ---- ---- ---- <> Numerical Analysis | Toys | Calculator | Mathematics| Example| Toys and Games | Games | Application | GUI ---- <> Development | Concept| Algorithm | Biology