ÿþ<HTML> <HEAD> <TITLE>Carleman Inequality program</TITLE> <META http-equiv=Content-Type content="text/html; charset=big5"> <style type="text/css"> v\:* { behavior: url(#default#VML); } </style> <!-- The Cauchy-Schwarz Master Class author --> <meta name="author" content="J. Michael Steele" /> <!-- XYGraph v2.3 code author --> <meta name="author" content="J. Gebelein" /> <!--carleman.htm author --> <meta name="author" content="Liu, HsinHan ‰Rk”"o &#21129;&#37995;&#28450;" /> <script type="text/javascript"> <!-- //2009-08-23-11-48 //If one function defined twice in a html file //MSIE accept the last definition, //MSIE ignore older definition //Netscape accept the first definition //Netscape ignore newer definition //LiuHH's file structure use MSIE method. //Netscape method not compatible with LiuHH's //file structure. //LiuHH's file structure define one function //twice on purpose. //LiuHH do not know what code to select browser //If user use Netscape to view this page, some //function can never work. For example gamma() //2009-08-23-11-56 // // //If can not load jsgraph2.js next definition is //effective, tell user where to get jsgraph2.js var msg01='document.getElementById("gotoFM2msg").innerHTML+=\''; var msg02=' goto online to get http://freeman2.com/jsgraph2.js<br>\';'; function stepf(t0,bgn0) //9712091955 {eval(msg01+'01'+msg02);} function loggamma(x) {eval(msg01+'02'+msg02);} function gamma(x) {eval(msg01+'03'+msg02);} function factorial(n) {eval(msg01+'04'+msg02);} function wipeCurve(d3) {eval(msg01+'05'+msg02);} function DrawGraf2(argd2) {eval(msg01+'06'+msg02);} function closeStr(klozID) {eval(msg01+'07'+msg02);} function toSyntax(inStr1) {eval(msg01+'08'+msg02);} function x2t(in0) {eval(msg01+'09'+msg02);} function deleteData(workID,probID) {eval(msg01+'10'+msg02);} function delAll(probID) {eval(msg01+'11'+msg02);} function openTable(drawID,table01) {eval(msg01+'12'+msg02);} function open0lxr(xx) {eval(msg01+'13'+msg02);} function closelxr(yy) {eval(msg01+'14'+msg02);} //9712092032 //if receive http://freeman2.com/jsgraph2.js // jsgraph2.js redefine above functions, //otherwise tell where to find jsgraph2.js function XYGraph(yy) {eval(msg01+'101'+msg02);} //9801260855 function XYLine(yy) {eval(msg01+'102'+msg02);} //9801260857 function Label(yy) {eval(msg01+'103'+msg02);} //9801260859 function tutelink() //9806231220 { document.getElementById("gotoFM2msg").innerHTML+= '50 goto online to get http://freeman2.com/tutelink.js<br>'; } function initial0(linkNum, plotNum) { tuteLink(0); //9806231221 //http://freeman2.com/tutelink.js //if use tutelink(0) when offline, get error 9711252125 spanAlertCarleman.innerHTML='' +'Please fill in your data to <a href=#program0>box 1</a> or click rand5, then click [C].' } function alert0() //9806161720 { document.write('<font color=red>' +'This file is personal home work. No one <br>' +'proofread. Cannot promise correctness. <br>' +'If you suspect any view point wrong, <br>' +'please ask a math expert near by. <br>' +'Freeman 2009-06-19-10-46</font> <br>' ); } //9806161724 function ineqIndexEn() //9806170948 { document.write('' +'<a name="index">&lt;a name="index"&gt;</a><a name="index01"></a> <br>' +'<font color=red size=+3>Can not load index file</font> <br>' +'Please download ineqinde.js Save to same folder as this file.<a href=http://freeman2.com/ineqinde.js> <br>' +'http://freeman2.com/ineqinde.js</a> <br>' ); } //9806170952 //If receive ineqinde.js //re-define function ineqIndexEn() //print index correctly. function alert1() //9806261745 { document.write('' +'<br><font color=red size=+3>' +'Following is exercise hint and solution. <br>' +'Suggest reader solve problem first, then <br>' +'use your solution compare with LiuHH&#39;s <br>' +'solution. LiuHH&#39;s sol. has no guarantee. <br>' +'Your solution could be better and correct. <br>' +'2009-07-28-10-16 <br>' +'</font><br>\n<br>\n<br>\n' ); } //function alert1() 9806261748 function alert2() //9806261808 { document.write('' +'0<font color=red size=+3>' +'LiuHH&#39;s sol. has no guarantee!</font>' ); } //function alert2() 9806261809 //2009-09-23-15-01 from tute0009.htm //find function readdata(inStr0) // function readdata(inStr0) //9806101151 { //9807270955 read other's no-comment code //very headache, now back to my code, add //more comments. // //if input inStr0 is Not a Number (isNaN=true) //then inStr0 is an array or string of char. if(isNaN(inStr0) //9807161944 //and if inStr0[0] is a Number //(isNaN=false) (!isNaN=true) //inStr0 is a number array, return oroginal form &&!isNaN(inStr0[0])) return inStr0; //if input inStr0 is empty, return oroginal form if(inStr0.length==0)return inStr0; //9806101153 //if input inStr0 is a number, return oroginal form if(!isNaN(inStr0[0]))return inStr0; //9807271000 //up to here input inStr0 is one string of character //below change string of char '1.23 4.56 7.89 ...' //to number array aa[0]=1.23, aa[1]=4.56, aa[2]=7.89 ... //9807271010 here //assume input string is '1.23 4.56 7.89 ...' //oArray[0] store '1.23' this is a string //oArray[1] store '4.56' not a number yet //oArray[2] store '7.89' convert to number later //9807271043 var oArray=''; //9806101158 var w0,w1,numb0; for(w0=0;w0<inStr0.length;w0++) { numb0=''; //skip those char are NOT [0123456789-+.] // [!(...)] means [is not ...] // [!=] means [not equal] 9807271051 // w1=w0; //9802172117 while(!(inStr0.charAt(w1)>='0' &&inStr0.charAt(w1)<='9') &&inStr0.charAt(w1)!='-' &&inStr0.charAt(w1)!='+' &&inStr0.charAt(w1)!='.' &&w1<inStr0.length ) { //index w1 increase only, //no record what read 9807271058 w1++; } //above while() loop stop at reading //either one in the list [0123456789-+.] //then start next while loop. 9807271055 // while((inStr0.charAt(w1)>='0' &&inStr0.charAt(w1)<='9') ||inStr0.charAt(w1)=='-' ||inStr0.charAt(w1)=='+' ||inStr0.charAt(w1)=='.' ||inStr0.charAt(w1)=='e' ||inStr0.charAt(w1)=='E' &&w1<inStr0.length ) //9802171608 { //If it is either one of [0123456789-+.eE] //continue store data into numb0 . 9807271102 numb0+=inStr0.charAt(w1); w1++; } //if all I get is just '.' for example // 'aa.txt' it is not a number, //no need to build output oArray //9807271106 if(numb0.length==1&&numb0.charAt(0)=='.') { w0=w1; //9802172218 //update index w0=w1 continue; //continue to next iteration. } //skip the following building code. //up to this point, numb0 is useful number //build output string oArray //9807271111 w0=w1; //9806101210 update index //string numb0 to output string oArray //add a newline byte '\n' to separate data // 9807271113 oArray+=numb0+'\n'; //9806101159 } // for(w0=0;w0<inStr0.length;w0++) //done for() loop, done output string oArray //use newline byte '\n' to separate numbers. // oArray.split('\n') in oArray cut data at //newline byte '\n' and change string // '1.23\n4.56\n7.89\n...' //to array oArray[0]='1.23', oArray[1]='4.56', //oArray[2]='7.89' ... //no matter input data use ',' or tab or //newline to separate data, here all done //9807271125 oArray=oArray.split('\n'); //9806101643 //string '1' + string '2' = '12' //number 1 + number 2 = 3 //above is string array oArray[0]='1.23', //below is number array w2[0]=1.23 //9807271130 var w2=[0,0]; for(w0=0;w0<oArray.length;w0++) { //9806101704 //parseFloat() convert string number // to number number. w1=parseFloat(oArray[w0]); //no more number? done if(isNaN(w1))break; //9806101714 w2[w0]=w1; //create number array. } return w2; } // function readdata() 9806101214 //from function update0() //9802171511 /** 9905030747 function datanorm(arg1,arg2) arg1 store data string arg2 store power number example outbox.value=datanorm([1,2,3,4,5],2) or outbox.value=datanorm(inBox.value,powBox.value) function datanorm() need another function readdata() to cinvert data from string to array. /**/ function datanorm(arg1,arg2) { //9905030751 var bx1a=readdata(arg1); var pow2=parseFloat(arg2); var bxSum=0; var bx; for(bx=0;bx<bx1a.length;bx++) bxSum+=Math.pow(Math.abs(bx1a[bx]),pow2); return 'Data array0'+pow2+'_norm is:' +Math.pow(bxSum,1/pow2); } //9905030753 //--> </SCRIPT> <script src="http://freeman2.com/tutelink.js" language="javascript"></script><!--9806111210--> <script src="tutelink.js" language="javascript"></script><!--9806111211--> <script type="text/javascript" src=jsgraph2.js> </script><!--9808261915--> </HEAD> <body link="#FF0000" vlink="#0000FF" alink="#50A000" bgcolor="#ccfcfc" onload="javascript:initial0()" > <span id="gotoFM2msg"></span><!--9712091951--> <font size=+2> Carleman Inequality program</a> </font> <br> <a href="#program0"> program </a> 0 <a href="#clickCarleman"> click </a> 0 <a href="#docB001"> help </a> &nbsp; Upload 2010-05-04 <br> <a href=http://www.structura.info/XYGraph/XYGraphDemo.htm> XYGraph v2.3 - web page graph </a> &nbsp; <!--9506231219 add link--> <a href=http://www.structura.info/XYGraph/Links.htm> && <!--##9756;##9758;--> </a> &nbsp; <!--9506231216 add link--> <a href=http://www.structura.info/XYGraph/Purchase.htm> donate<!--9801031950 use donate ##9829;##9835; e&k&--> </a> &nbsp; <a href="http://www.structura.info/XYGraph/XYGraph.zip"> get code</a> <!-- 2006-06-12-18-21 download http://www.structura.info/XYGraph/XYGraph.zip C:\$fm\js\xygraph\XYGraph.zip 2006-06-19-08-21 record --> <br> <a href=http://www-stat.wharton.upenn.edu/~steele/Publications/Books/CSMC/CSMC_index.html> The Cauchy-Schwarz Master Class </a> &nbsp; <a href=http://www-stat.wharton.upenn.edu/~steele/index.html> J. Michael</a> <a href=http://www.wharton.upenn.edu/faculty/steele.html> Steele</a> &nbsp; <a href=http://www.amazon.com/review/product/052154677X/ref=cm_cr_dp_all_helpful?%5Fencoding=UTF8&coliid=&showViewpoints=1&colid=&sortBy=bySubmissionDateDescending> &&&&& </a><!--9806081839 add link--> <br> <font color=red> This file is personal home work. No one <br> proofread. Cannot promise correctness. <br> If you suspect any view point wrong, <br> please ask a math expert near by. <br> Freeman 2009-06-19-10-46</font> <br> Please use MSIE browser to read this file. <br> Did not test other browser. This file is <br> <!--9806081846--> written under MSIE 6.0 <br> <span id="tuteLink1"></span> <br> <script src="http://freeman2.com/rocsitee.js" language="javascript"></script> <br> <a name="program0"></a> Arithmetic Mean and Geometric Mean of a number sequence <br> <font color=red> Output may contain error, Please verify first. <br> Program environment is MSIE 6.0, please use MSIE </font> <br> <font color=red><b> Main click button is <a href=carleman.htm#clickCarleman>here</a>. Click 'rand5' first, then click 'C'. </b></font> <br> Box 1 input &nbsp; <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("boxc01").value.toString())' type=button value="copy 1"> <INPUT onclick='document.getElementById("boxc01").value=""' type=button value="del 1"> <a href=http://freeman2.com/complex2.htm#calculator> Calculator</a> <a href=complex2.htm#calculator>local</a> <!--9809092259 add link to calculator--> <br> <TEXTAREA id=boxc01 name=boxc01 rows=10 cols=70 > 2 1.6 0.9 0.65 0.1 </TEXTAREA> <!--9809261017 use box 1--> <br> <font color=red><!--980910011850--> Carleman's inequality require input sequence infinite sum be bounded. </font> <br> <a name=controlCenter></a> <br> <!--9904091538--> x min: <INPUT id=QBboxXmin10 value="0" size=3 > , x max: <INPUT id=QBboxXmax10 value="10" size=3 > ; y min: <INPUT id=QBboxYmin10 value="-10" size=3 > , y max: <INPUT id=QBboxYmax10 value="10" size=3 > ; <br> Drawing board size W: <INPUT id=QBboxWidth10 value="300" size=5 onchange="javascript:if(QBboxWidth10.value<100)QBboxWidth10.value=100; else if(QBboxWidth10.value>800)QBboxWidth10.value=800;" > H: <INPUT id=QBboxHeight10 value="300" size=5 onchange="javascript:if(QBboxHeight10.value<100)QBboxHeight10.value=100; else if(QBboxHeight10.value>800)QBboxHeight10.value=800;" > <INPUT id=QBchkbxComplex type="checkbox" ><a href="#docB006">complex</a><!-- 9905010537 add to match fillRand5(), random#5--> <br> <table border=1> <tr> <td> <input onclick="javascript:boxc02.value=amgmf1(boxc01.value,1)" type="button" value="0AM GM 1" /> </td> <td> <input onclick="javascript:boxc02.value=amgmf1(boxc01.value,2);if(spanAlert1.innerHTML=='')spanAlert1.innerHTML='Carleman1 inequality GG<=E*IN, general purpose. Use E=2.7...'" type="button" value="0Carle man1" /> <!--9809281718--> <input type="button" value="Carle man2" onclick="javascript:carlemanf2();if(spanAlert1.innerHTML=='')spanAlert1.innerHTML='<font color=red>Carleman2 inequality, monotone in/decrease data. read [powData]</font>'" /> <!--9809291117del; 9809300028 use--> <input type="button" value="Carle man3" onclick="javascript:carlemanf3();if(spanAlert1.innerHTML=='')spanAlert1.innerHTML='<font color=red>Carleman3 inequality with Gradual AM seq. & Gradual GM seq.</font>'" /> <input type="button" value="dbg" onclick="chkbxcD1.checked=chkbxcD2.checked=chkbxcD3.checked=chkbxcD4.checked=0" /> <!-- onclick="chkbxcD1.checked='1'" /> --> a<input type="checkbox" name="chkbxcD1" id="chkbxcD1" />,b<input type="checkbox" name="chkbxcD2" id="chkbxcD2" />,c<input type="checkbox" name="chkbxcD3" id="chkbxcD3" />;d<input type="checkbox" name="chkbxcD4" id="chkbxcD4" /> </td> </tr> <tr> <td> <a href="#docB001"> help_1</a><!--9809291319--> </td> <td> <input type="button" value="±" onclick="boxAlpha.value=''" /> <INPUT value="" id=boxAlpha size=2 ><!--9809271021--> , <input type="button" value="É" onclick="boxOmega.value=''" /> <INPUT value="" id=boxOmega size=2 ><!--9809271022--> <INPUT id="chkbxcB0" type="checkbox" onclick="if(chkbxcB0.checked)boxOmega.value=0.36787944117144233;else boxOmega.value=''" ><a href="#docA017">1/E</a> ; <INPUT id="chkbxcB1" type="checkbox" onclick="chkbxcB2.checked=0" >123 , <INPUT id="chkbxcB2" type="checkbox" onclick="chkbxcB1.checked=0" checked ><a href="#docB014">321</a> </td> </tr> <tr> <td> <!--9809261456--> <input type="button" value="equal #" onclick="javascript: var eq0=boxcA4.value; var ou0=''; for(var d0=0;d0<parseInt(boxcA1.value);d0++) ou0+=eq0+'\n'; boxc01.value=ou0; " /> </td> <td> <a href="#docB027">10^</a> <INPUT value="0.301" id=boxcA4 size=5 > ; <INPUT id="chkbxcA2" type="checkbox" onclick="chkbxcA3.checked=!chkbxcA2.checked" checked >+/0 , <INPUT id="chkbxcA3" type="checkbox" onclick="chkbxcA2.checked=!chkbxcA3.checked" >+/0/- ; <INPUT value="8" id=boxcA3 size=5 > digits </td> </tr> <tr> <td> <input type="button" value="rand5" onclick="javascript: boxc01.value=fillRand5( QBchkbxComplex.checked, boxcA4.value, boxcA3.value, boxcA1.value, chkbxcA3.checked, chkbxcA1.checked); if(!QBchkbxComplex.checked) { if(chkbxcB1.checked||chkbxcB2.checked) { var randStr=readdata(boxc01.value); bubble_1(randStr,randStr.length); boxc01.value=(''+randStr).replace(/,/g,'\n'); } if(chkbxcB1.checked) boxc01.value=upsidedown2(boxc01.value) } " /> <!-- 99,05,01,11,36 add next 'if' if(!QBchkbxComplex.checked){...} so that complex output will show up. readdata(boxc01.value) erase imaginary. complex output no sort ! --> </td> <td> fill <INPUT value="100" id=boxcA1 size=5 > numbers; <input type="checkbox" name="chkbxcA1" id="chkbxcA1" /> integer; <a href="#ch02b002"> Carleman ineq. </a> </td> </tr> </table> Above is random number. Main click button is <a href=carleman.htm#clickCarleman>here</a> 'C' <br> Below is equal space number. Output to box 1 above. <table> <tr> <td> <input type="button" value="powData" onclick="javascript:boxc01.value=powdata1()" /> </td> <td> <a href="#docB010">Bgn</a> <INPUT value="100" id=boxcC1 size=4 > ,# Step <INPUT value="99" id=boxcC2 size=4 > ,<a href="#docB018">End</a> <INPUT value="1" id=boxcC3 size=4 > </td> </tr> <tr> <td> <a href="#docB018">power</a> </td> <td> <INPUT value="1" id=boxcE1 size=4 > <!--9809291148--> Set to 1 to get what you expected. </td> </tr> </table> If set power to -2, all output number raise to power -2 <br> "[k=1,"]1/k<sup>2</sup>=À<sup>2</sup>/6=1.64493406684... <!--9905022114--> <input type="button" value=""" onclick="javascript: var bx1a=readdata(boxc01.value); var bxSum=0; for(var bx=0;bx<bx1a.length;bx++) bxSum+=bx1a[bx]; spanAlert1.innerHTML='Box 10sum to:'+bxSum; " /> <!--9905022118--> <INPUT value="1.25" id=boxcF1 size=4 > <!--9905022236 --> <!--9905022237 build; 9905030746 del -/-/> <input type="button" value="N" onclick="javascript: var bx1a=readdata(boxc01.value); var bxSum=0; var pow2=parseFloat(boxcF1.value); for(var bx=0;bx<bx1a.length;bx++) bxSum+=Math.pow(Math.abs(bx1a[bx]),pow2); spanAlert1.innerHTML='Box 10'+pow2+'_norm is:' +Math.pow(bxSum,1/pow2); " /> <!-- 9905022238 --> <!--9905030754--> <input type="button" value="N" onclick="javascript: spanAlert1.innerHTML= datanorm(boxc01.value,boxcF1.value); " /> <!--9905030756--> <!--9905031643--> <input type="button" value=""" onclick="javascript: var bx1a=readdata(boxc01.value); var bxProd=1; for(var bx=0;bx<bx1a.length;bx++) bxProd*=bx1a[bx]; spanAlert1.innerHTML='Box 10product to:'+bxProd; " /> <!--9905031645 --> <a href="#docB019">?</a> <br> <span id=spanAlert1> <font color=red> Set power value < -1, click [powData] get bounded sequence. </font> </span><!--9809291516--> <br> Box 2 Sum(log(1/a_i)) &nbsp; <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("boxc02").value.toString())' type=button value="copy 1"> <INPUT onclick='document.getElementById("boxc02").value=""' type=button value="del 1"> <a href=http://freeman2.com/complex2.htm#calculator> Calculator</a> <a href=complex2.htm#calculator>local</a> <!--9809092259 add link to calculator--> <a href="#docB021">?</a> <br> <TEXTAREA id=boxc02 name=boxc02 rows=10 cols=70 > Carleman's inequality require that input sequence all elements be positive, infinite many elements, sum of infinite many elements be finite. Only monotone decrease infinite many elements sequence can participate Carleman's inequality. In Bgn box fill '1', in End box fill '100' in power box fill a value < -1 for Carleman sequence. If power=-1, integral of 1/x = log(x) is divergent !! Click "powData" then click "Carle man3" for answer. </TEXTAREA><!--9810012001 to 9810012009 add box2 comment--> <br> <a name="clickCarleman"></a> A=Gradual GM; B=Sum(log(1/a_i)); C both; <a href="#docB024"><font color=red><b>D for fig.11.2</b></font></a> <br> <!--9904301532--> <a href="#ch02b002"> Carleman</a> 0<input type="button" value="A" onclick="javascript:var watch0=carlemanf4(1); if(watch0.length) spanAlertCarleman.innerHTML=watch0; else spanAlertCarleman.innerHTML='Click [C] draw both curve; <a href=#program0>box 1</a> for input data.'; " /> <!--9904301746--> <input type="button" value="B" onclick="javascript:var watch0=carlemanf4(2); if(watch0.length) spanAlertCarleman.innerHTML=watch0 else spanAlertCarleman.innerHTML='Click [C] draw both curve; <a href=#program0>box 1</a> for input data.'; " /> <!--9905010737--> <input type="button" value="rand5" onclick="javascript: boxc01.value=fillRand5( QBchkbxComplex.checked, boxcA4.value, boxcA3.value, boxcA1.value, chkbxcA3.checked, chkbxcA1.checked); if(chkbxcB1.checked||chkbxcB2.checked) { var randStr=readdata(boxc01.value); bubble_1(randStr,randStr.length); boxc01.value=(''+randStr).replace(/,/g,'\n'); } if(chkbxcB1.checked) boxc01.value=upsidedown2(boxc01.value) " /> <!--9904301957--> <input type="button" value="C" onclick="javascript:var watch0=carlemanf4(3); if(watch0.length) spanAlertCarleman.innerHTML='<font color=red>'+watch0+'</font>' else spanAlertCarleman.innerHTML='Both curves scaled to fit drawing board. <a href=#program0>box 1</a> for input data.'; " /> <input type="button" value="pow" onclick="javascript:boxc01.value=powdata1()" /> <input type="button" value="wipe" onclick="spanAlertCarleman.innerHTML='Thank you for visiting <a href=http://freeman2.com/freeman2.htm#whatsnew>Freeman web site</a>. <a href=#program0>box 1</a> for input data.'; divGraphCarleman.innerHTML=''; spanEqnDocCarleman.innerHTML=''; " /> <!--9905021738--> <input type="button" value="D" onclick="javascript: boxc01.value='2\n1.6\n0.9\n0.65\n0.1'; var watch0=carlemanf4(3); if(watch0.length) spanAlertCarleman.innerHTML='<font color=red>'+watch0+'</font>' else spanAlertCarleman.innerHTML='Simple example from <a href=tute0041.htm#ch11b089>tute0041.htm</a> <a href=#program0>box 1</a> for input data.'; spanEqnDocCarleman.innerHTML='Please click for <a href=tute0041.htm#ch11b082>Figure 11.2 document</a>'; " /> <a href=#controlCenter>ControlCenter</a> <br> <font color=red> <span id=spanAlertCarleman> </span> </font> <br> <div id=divGraphCarleman></div> <br> <span id=spanEqnDocCarleman> <!--9904301627--> </span> <br> <a name="boxb13Here"></a> <table border=0> <tr> <td> Box 3, debug <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("QGboxb13").value.toString())' type=button value="copy3"> <INPUT onclick='document.getElementById("QGboxb13").value=""' type=button value="del3"> <br> <TEXTAREA id=QGboxb13 name=QGboxb13 rows=6 cols=30 > </TEXTAREA> </td> <td> Box 4, debug <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("QGboxb14").value.toString())' type=button value="copy4"> <INPUT onclick='document.getElementById("QGboxb14").value=""' type=button value="del4"> <br> <TEXTAREA id=QGboxb14 name=QGboxb14 rows=6 cols=30 > </TEXTAREA> </td> </tr> </table> <a href='http://freeman2.com/tute0012.htm#ch02b001'> tute0012.htm </a> &nbsp; <a href='tute0012.htm#ch02b001'> local </a> <br> Box 1 is user input sequence, monotone decrease, positive. <br> Box 2 is Sum(log(1/a_i)), box 4 same, scaled to fit board. <br> Box 3 is gradually GMed seq. Box 3 upper curve, Box 4 lower. <br> <script language="javascript">alert0()</script> <!--9809261024 use box 2--> <script language="javascript"> <!-- //both "AM/GM 1" button and //"Carleman1" button use function amgmf1() //but //"Carleman2" button use function carlemanf2() //"AM/GM 1" button do not use debug checkbox //"Carleman1" button use debug checkbox // function amgmf1(agArg1,agArg2) //9809261150 { var inp0=readdata(agArg1) var j0,j1,j2,j3,j4,j5; var len0=inp0.length var am0=0; var gm0=1; //j1=1/len0; var gmPow=1/len0; //9810051143 spanAlert1.innerHTML=''; //9809291518 j1=0; for(j0=0;j0<len0;j0++) { if(inp0[j0]<0)j1=1; //9809291521 am0+=inp0[j0]/len0; //gm0*=Math.pow(inp0[j0],j1); //9809261046 gm0*=Math.pow(inp0[j0],gmPow); //9810051143 //gm0*=Math.pow(inp0[j0],1/len0); //9810051155 //9810051600 pow($,gmPow) is //better than pow($,1/len0) //if sequence has 2000 elements //gmPow=1/len0; carry out division once //pow($,1/len0) carry out division 2000 times //9810051602 } if(j1==1) spanAlert1.innerHTML='' //9809291518 +'<font color=red>ALERT ! box1 has negative number! AMGM do not treat negative!</font>' ; var sum0=bye09(am0*len0); if(agArg2==1) //"AM/GM 1" button return here return 'AM='+bye09(am0)+'\n' //9809261039 +'GM='+bye09(gm0)+'\n' +'SUM='+sum0+'\n' +'Product='+bye09(gm0)+'^'+len0+'='+bye09(Math.pow(bye09(gm0),len0))+'\n' +'Number of elements='+len0+'\n9809261039\n' //9809261700 if(agArg2==2) //Carleman's inequality, { //textbook page 27, eqn.2.15 var carlrite=Math.E*sum0; //9809261705 var carlleft=0; var carleman=0; var carlpart=''; //9809270755 var inp0sum=0; //9809270813 var dbg1=chkbxcD1.checked; //9809281920 twoseq var dbg2=chkbxcD2.checked; //9809291252 carlrite var dbg3=chkbxcD3.checked; //9809291253 carlleft var crite="" //9809271047 +"Weight alpha (has theory base) and\n" +"weight omega (NO theory base) are\n" +"both not set. The result is true\n" +"Carleman's inequality." var twoseq=''; //9809272121 if(dbg1) twoseq= "Carleman's inequality work with the following two sequences\n" +"input sequence and gradual GMed sequence\n"; var alpha0=parseFloat(boxAlpha.value); //9809271025 var omega0=parseFloat(boxOmega.value); var weight0=0; var weight1=1; var wchoose=0; if(!isNaN(alpha0)) {weight0=alpha0;wchoose=1;} else if(!isNaN(omega0)) //9809271029 { wchoose=2; crite='' +'if set omega<1, Carleman inequality greater\n' +'than side value reduce. There is no theory\n' +'base for this setting. Purely try and error.\n' +'Now omega setting is '+omega0+'\n' +'*** if set omega=1/E=0.36787944117144233\n' +'*** cancel E in E*SUM[k=1,n]{weight*ak}\n' +'*** inequality become uncertainty.\n' +'Without omega setting, carlrite='+carlrite+'\n' +'With omega setting, carlrite=' +(carlrite*omega0)+'\n'; //9809271059 carlrite=carlrite*omega0; //9809271100 } //if(!isNaN(omega0)) if(wchoose==1) //9809271035 { sum0=0; for(j0=0;j0<len0;j0++) //9809261729 { //modify carlrite weight1=(1-(1-Math.pow(2,1+alpha0)/Math.E)/(j0+1))/Math.pow(1+1/(j0+1),alpha0); sum0+=weight1*inp0[j0]; } crite='' //9809271054 +'2009-09-02-22-06 LiuHH access\n' +'http://www.emis.de/journals/JIPAM/images/029_00_JIPAM/029_00_www.pdf\n' +'if set 0<=alpha<=1/log(2)=1.4426950408889633\n' +'Carleman inequality two side difference will\n' +'reduce. Now alpha setting is '+alpha0+'\n' +'Without alpha setting, carlrite='+carlrite+'\n' +'With alpha setting, carlrite='+(Math.E*sum0)+'\n' +'alpha change weight in E*SUM[k=1,n]{weight*ak}\n' ; carlrite=Math.E*sum0; //9809271045 } //if(wchoose==1) /** JIPAM-029_00 page 9/10 theorem 3.2 add weight 2009-09-29-11-00 add next working record, show JIPAM-029_00 page 9/10 theorem 3.2 used here 2009-09-02-22-06 LiuHH access http://www.emis.de/journals/JIPAM/images/029_00_JIPAM/029_00_www.pdf save as carleman-029_00_JIPAM-029_00_www.pdf [[ Carleman s inequality without weight SUM[k=1,n]{a1*a2*...*ak}^(1/k) <= <= E*SUM[k=1,n]{ak} and n goto inf. ]] 9809270849 carleman-029_00_JIPAM-029_00_www.pdf page 9/10 theorem 3.2 add weight [[ Carleman s inequality with weight SUM[k=1,n]{a1*a2*...*ak}^(1/k) <= <= E*SUM[k=1,n]{weight*ak} and n goto inf. ]] k in weight match k in ak (a1,a2,a3...ak) weight=(1-beta/k)/[(1+1/k)^alpha] 0<=alpha<=1/log(2)=1.4426950408889633 0<=beta <=1-2/E=0.26424111765711533 and E*bata+2^(1+alpha)=E 9809270854 if alpha=0, beta=1-2/E if beta=0, alpha=-1+1/log(2) bata=1-2^(1+alpha)/E weight=(1-beta/k)/[(1+1/k)^alpha] weight=(1-(1-2^(1+alpha)/E)/k)/[(1+1/k)^alpha] weight=(1-(1-pow(2,1+alpha)/E)/k)/pow(1+1/k,alpha) 9809270906 above is comment for if(wchoose==1) when user fill number in alpha box, and click Carleman1 button, program use alpha value. 2009-09-29-11-11 /**/ for(j0=1;j0<=len0;j0++) //9809261729 { inp0sum+=inp0[j0-1]; //9809270814 carleman=1; j2=1/j0; //9809261710 j3=1; for(j1=0;j1<j0;j1++) { carleman*=Math.pow(inp0[j1],j2); //9809261711 j3=j3*inp0[j1]; //9809270803 } carlleft+=carleman; //9809261712 if(dbg3) //this is heavy output { carlpart+='' //9809270805 +j0+stndrdth(j0)+' term: product='+j3 +', power=1/'+j0+'='+j2 +', value='+bye09(carleman) +', sum='+bye09(carlleft) +'\n' } if(dbg1) { twoseq+=inp0[j0-1]+'\t\t' +bye09(carleman)+'\n'; //9809272119 } } inp0sum=bye09(inp0sum); carlrite=bye09(carlrite); carlleft=bye09(carlleft); //9809262216 //9809281252 //Carleman's inequality GG<=E*IN //Gradual GMed sum <= E*INput sum // SUM[k=1,n]{a1*a2*...*ak}^(1/k)<= E*SUM[k=1,n]{ak} // next ggin means GG/IN, drop E=2.71828... // because if data is monotone increase // GG/IN always <1, no need multiply E var ggin=carlleft/inp0sum; //9809281257 // on the other hand if data is monotone // decrease, GG/IN always >1, and // worst case input data 9,8,7,6,5,4,3,2,1 // GG/IN=1.3493016626997747 // 9809281307 if(dbg1) twoseq+='' +'E*(sum of input) is carlrite, gradual GMed sum is carlleft.\n' +'Sum of gradual GMed <= E*(sum of input).\n' return "Carleman's inequality GG<=E*IN\n" +"Gradual GMed sum <= E*INput sum\n" +"Drop E, GG/IN="+ggin+"\n" //9809281249 +"SUM[k=1,n]{a1*a2*...*ak}^(1/k) <=\n" +"<= E*SUM[k=1,n]{ak} and n goto inf.\n" +"where E=2.718281828459045...\n" +"carlleft <= carlrite answer is next\n" +carlleft+"<="+carlrite+"\n" +((wchoose==1)?"You fill data in alpha box, weights added\n":"") +((wchoose==2)?"You fill data in omega box, E is not used\n":"") +((wchoose==2&&chkbxcB0.checked)?"You checked 1/E box, E replaced by 1\n":"") +"Equality occurs if and only if any\n" +"one input sequence number is zero.\n" +"Answer is not confirmed, may be wrong!!\n\n" +crite+"\n" +((dbg2)?"" +"===== carlrite is next ===== 9809261719\n" +"inp0="+inp0+"\n" +"inp0sum="+inp0sum+"\n" +"E=2.718281828459045...\n" +"carlrite="+carlrite+"\n" :"") +((dbg3)?"" +"===== carlleft is next =====\n" +carlpart +"carlleft=last sum="+carlleft+"\n\n" :"") +((dbg1)?"" +"===== Two sequences =====\n" +twoseq //9809272059 :"") ; } //if(agArg2==2) //Carleman's inequality return 'working'; } //function amgmf1(agArg1,agArg2) 9809261202 /** 2009-09-28-17-23 Carleman's inequality SUM[k=1,n]{a1*a2*...*ak}^(1/k) <= <= E*SUM[k=1,n]{ak} and n goto inf. where E=2.718281828459045... right hand side {ak} is input data left hand side {a1*a2*...*ak}^(1/k) is gradually GMed term if {ak} is monotone increase, no need E each term {a1*a2*...*ak}^(1/k) < {ak} if {ak} is monotone decrease, if no E each term {a1*a2*...*ak}^(1/k) > {ak} in this case E*{ak} reverse inequality if {ak} is monotone increase and equal step size, result is best case {a1*a2*...*ak}^(1/k)/{ak} < 1 and maximum if {ak} is monotone decrease and equal step size, result is worst case {a1*a2*...*ak}^(1/k)/{ak} > 1 and minimum In worst case SUM E*{ak} will reverse the inequality. function carlemanf2() drop E, try evaluate {a1*a2*...*ak}^(1/k)/{ak} see if this value approach E = 2.718281828459045 2009-09-28-17-35 /**/ function carlemanf2() //9809281736 { var inStr0=boxc01.value=powdata1() var ouStr0=''; var d0,d1,d2,d3,d4,d5; var sumin=0; //sum if input data var sumgm=0; //sum of gradually GMed terms var progm=1; //product of gradually GMed terms //var onegm=0; //sumgm^(1/d0) var onegm=1; //sumgm^(1/d0); //9809281830 var dbg4=chkbxcD4.checked; //9809291150 for(d0=inStr0.length-1;d0>0;d0--) { if(inStr0.charCodeAt(d0)<32) continue; else break; //9809281203 } d1=inStr0.substring(0,d0+1); d1=d1.split('\n'); d2=['']; for(d0=0;d0<d1.length;d0++) { d2[d0]=parseFloat(d1[d0]); } inStr0=d2; d1=d2=''; ouStr0='' //9809281858 +'If input data monotone decreasing, sumgm/sumin>1, need E\n' +' to reverse the inequality to sumgm < E*sumin .\n' +'If input data monotone increasing, sumgm/sumin<1, no need E\n' +'If data increase/decrease/in/de etc., sumgm ?<?>? sumin\n' +'The following output, no E involve. Hope find sumgm/sumin>1\n' +'case, see sumgm/sumin ratio approach E=2.718281828459045...\n' //+'input data sum, GMed data sum, sumgm/sumin, GM 1 term\n' +(dbg4?'Debug box_d is checked.\n' +'\nsumgm/sumin, GMed data sum, input data sum, GM 1 term' :'Debug box_d is not checked.\n\nsumgm/sumin' ) +'\n' ; d2=0; //9809291532 for(d0=1;d0<=inStr0.length;d0++) { if(inStr0[d0-1]<0)d2=1; //9809291533 sumin+=inStr0[d0-1]; onegm=1; //9809281847 for(d1=0;d1<d0;d1++) { //9809281836 onegm*=Math.pow(inStr0[d1],1/(d0)); } sumgm+=onegm; ouStr0+=(sumgm/sumin) +(dbg4?'' +'\t'+sumgm +'\t'+sumin +'\t'+(onegm) :'' ) +'\n' } //for(d0=1;d0<=inStr0.length;d0++) spanAlert1.innerHTML=''; if(d2==1) spanAlert1.innerHTML='' //9809291534 +'<font color=red>ALERT ! box1 has negative number! Carleman do not treat negative!</font>' ; boxc02.value=ouStr0 +'\n' +'Only last line is real Carlemans inequality answer.\n' +'Because C.ineq. say input data TOTAL sum eqn. is\n' +'Gradual GMed total sum <= E*INput total sum\n' +'9809281906\n' } //function carlemanf2() //9809281736 //9809300030 //input raw data sequence //gradual GMed sequence //gradual AMed sequence function carlemanf3() //9809300030 { var inp0=readdata(boxc01.value) var j0,j1,j2,j3,j4,j5; var len0=inp0.length var am0=0; var gm0=1; var gmPow=1/len0; //9810051150 spanAlert1.innerHTML=''; //9809291518 j1=0; for(j0=0;j0<len0;j0++) { if(inp0[j0]<0)j1=1; //9809291521 am0+=inp0[j0]/len0; gm0*=Math.pow(inp0[j0],gmPow); //9810051151 } if(j1==1) spanAlert1.innerHTML='' //9809291518 +'<font color=red>ALERT ! box1 has negative number! AMGM do not treat negative!</font>' ; var sum0=bye09(am0*len0); var threeseq=''; //9809300035 var gradualAM='';//9809300040 var inp0sum=0; var grAMsum=0; var grGMsum=0; for(j0=1;j0<=len0;j0++) //9809261729 { inp0sum+=inp0[j0-1]; //9809270814 gradualAM=inp0sum/j0; grAMsum+=gradualAM; //9809300107 carleman=1; j2=1/j0; //9809261710 j3=1; for(j1=0;j1<j0;j1++) { carleman*=Math.pow(inp0[j1],j2); //9809261711 } grGMsum+=carleman; //9809300108 threeseq+=inp0[j0-1]+'\t\t' +bye09(gradualAM)+'\t\t' //9809300045 +bye09(carleman)+'\n' //9809272119 ; } //for(j0=1;j0<=len0;j0++) //9809261729 threeseq+='\t\t=====\n' //9809300110 +inp0sum+'\t\t' +bye09(grAMsum)+'\t\t' +bye09(grGMsum)+'\n' +'GA/IN='+(grAMsum/inp0sum)+'\n' +'GG/IN='+(grGMsum/inp0sum)+'\n' +'IN = sum of INput sequence\n' +'GA = sum of Gradual AMed sequence\n' +'GG = sum of Gradual GMed sequence\n' +'Many test show GG/IN far below E=2.718281828459045...\n' +'This test show GA/IN still below E=2.718281828459045...\n' +'Only monotone decrease sequence approach E\n' +'If monotone increase sequence we can relax.\n' +'(Carleman inequality: GG<=E*IN or max(GG/IN)=E .\n' +' if monotone increase GG/IN<1<E=2.718281...\n' +' for a GG/IN<1 case, why do we bother GG/IN=E ?\n' +' so, relax! 2009-09-30-07-58 LiuHH add note.)\n' inp0sum=bye09(inp0sum); boxc02.value="" +"GA/IN="+(grAMsum/inp0sum)+"\n" +"GG/IN="+(grGMsum/inp0sum)+"\n" +"Carleman's inequality forget gradual AMed sequence\n" +"Carleman's inequality say the following (GG<=E*IN)\n" +"Gradual GMed sum <= E*INput sum\n" +"SUM[k=1,n]{a1*a2*...*ak}^(1/k) <=\n" +"<= E*SUM[k=1,n]{ak} and n goto inf.\n" +"This output not multiply E=2.718281828459045...\n" //9809300048 +"This output add gradual AMed sequence\n" //9809300054 +"Output the following three sequences\n" +"INput sequence; Gradual AMed sequence; Gradual GMed sequence\n" +threeseq //9809300050 ; } //function carlemanf3() 9809300051 //9809300030 //input raw data sequence //gradual GMed sequence //gradual AMed sequence function carlemanf4(arg1) //9904301528 { var inp0=readdata(boxc01.value) var j0,j1,j2,j3,j4,j5; var len0=inp0.length var am0=0; var gm0=1; var gmPow=1/len0; //9810051150 //make sure input has non-negative only spanAlert1.innerHTML=''; //9809291518 j1=0; for(j0=0;j0<len0;j0++) { if(inp0[j0]<0)j1=1; //9809291521 am0+=inp0[j0]/len0; gm0*=Math.pow(inp0[j0],gmPow); //9810051151 } if(j1==1) spanAlert1.innerHTML='' //9809291518 +'<font color=red>ALERT ! box1 has negative number! AMGM do not treat negative!</font>' ; var sum0=bye09(am0*len0); var GMedSeq=''; //9809300035 var gradualAM='';//9809300040 var inp0sum=0; var grAMsum=0; var grGMsum=0; var maxData1=0; //9904301921 var maxData2=0; //9904302000 if(arg1==1||arg1==3) { for(j0=1;j0<=len0;j0++) //9809261729 { inp0sum+=inp0[j0-1]; //9809270814 gradualAM=inp0sum/j0; grAMsum+=gradualAM; //9809300107 carleman=1; j2=1/j0; //9809261710 j3=1; for(j1=0;j1<j0;j1++) { carleman*=Math.pow(inp0[j1],j2); //9809261711 } grGMsum+=carleman; //9809300108 if(carleman>maxData1) maxData1=carleman; //9904301928 GMedSeq+='' +bye09(carleman)+'\n' //9904301540 ; } //for(j0=1;j0<=len0;j0++) //9809261729 boxc02.value="" //+maxData1+'\n' //9905021545 use; 9905021555 del +GMedSeq //9904301536 ; } //if(arg1==1||arg1==3) //else if(arg1==2||arg1==3) { var logInvS=[]; //9904301758 log inversed sequence. var logInv0=0; var logInv1=''; for(j0=1;j0<=len0;j0++) //9904301806 { logInv0=0; //9904301846 for(j1=0;j1<j0;j1++) { logInv0+=Math.log(1/inp0[j1]); } logInv1+='' +bye09(logInv0)+'\n' //9904301814 logInvS[j0-1]='' +bye09(logInv0)+'\n' //9904301804 ; if(Math.abs(logInv0)>maxData2 //normalize curve to fit in drawing board //normalize curve divide max. function value //if one point damage ='Infinity', //allow most part of curve show up. //9905021657 use next line &&Math.abs(logInv0)<'Infinity' ) maxData2=Math.abs(logInv0); //9904301930 } //for(j0=1;j0<=len0;j0++) //9809261729 boxc02.value="" +logInv1 //9904301815 +'\n\nmaxData2=' //9905021655 +maxData2 ; } // if(arg1==2||arg1==3) //9904301640 var MyGraph = new XYGraph(); var MyLine1 = new XYLine(); var MyLine2 = new XYLine(); MyLine1.VMLpointshapetype="none"; MyLine2.VMLpointshapetype="none"; status=''; var err0='Input data error: '; //9904301649 var ymax0=parseFloat(QBboxYmax10.value) if(isNaN(ymax0)) return err0+'ymax='+'['+QBboxYmax10.value+']'; MyGraph.ymax=ymax0; var ymin0=parseFloat(QBboxYmin10.value) if(isNaN(ymin0)) return err0+'ymin='+'['+QBboxYmin10.value+']'; MyGraph.ymin=ymin0; var xmax0=parseFloat(QBboxXmax10.value) if(isNaN(xmax0)) return err0+'xmax='+'['+QBboxXmax10.value+']'; MyGraph.xmax=xmax0; var xmin0=parseFloat(QBboxXmin10.value) if(isNaN(xmin0)) return err0+'xmin='+'['+QBboxXmin10.value+']'; MyGraph.xmin=xmin0; if(xmin0>=xmax0)return err0+'xmin>=xmax'; if(ymin0>=ymax0)return err0+'ymin>=ymax'; MyGraph.gheight=QBboxHeight10.value; MyGraph.gwidth=QBboxWidth10.value; MyGraph.title= "ISBN 978-0-521-54677-5 page 175 Figure.11.2"; var dbg13=''; //9904301724 var dbg14=''; //9904302003 GMedSeq=readdata(GMedSeq); //9904301731 if(arg1==1||arg1==3) { MyLine1.x[0] =0 //9905021641 MyLine1.y[0] = //attempt insert (0,y_max) GMedSeq[0]*(ymax0-0)/maxData1; dbg13+='' //9905021646 +MyLine1.x[0]+',' +MyLine1.y[0]+'\n' for(j1=0;j1<len0;j1++) //9904301822 use len0 { //9904301709 //MyLine1.x[j1] =j1*(xmax0-xmin0)/GMedSeq.length //9905021640 //MyLine1.x[j1] =(j1+1)*(xmax0-xmin0)/GMedSeq.length //MyLine1.y[j1] =GMedSeq[j1]*(ymax0-0)/maxData1; //9904301930 MyLine1.x[j1+1] =(j1+1)*(xmax0-xmin0)/GMedSeq.length MyLine1.y[j1+1] =GMedSeq[j1]*(ymax0-0)/maxData1; //9904301930 dbg13+='' //9904301726 +MyLine1.x[j1+1]+',' +MyLine1.y[j1+1]+'\n' } //for(j1=0;j1<len0;j1++) } //if(arg1==1||arg1==3) if(arg1==2||arg1==3) { MyLine2.x[0] = //9905021636 MyLine2.y[0] =0; //attempt insert (0,0) dbg14+='' //9904302005 +MyLine2.x[0]+',' +MyLine2.y[0]+'\n' for(j1=0;j1<len0;j1++) //9904301822 use len0 { //9904301709 //MyLine2.x[j1+1] =j1*(xmax0-0)/logInvS.length //9905021638 use '(j1+1)' //attempt insert (0,0) MyLine2.x[j1+1] =(j1+1)*(xmax0-0)/logInvS.length MyLine2.y[j1+1] =logInvS[j1]*(0-ymin0)/(maxData2); //9904301931 dbg14+='' //9904302005 +MyLine2.x[j1+1]+',' +MyLine2.y[j1+1]+'\n' } //for(j1=0;j1<len0;j1++) } //if(arg1==2||arg1==3) MyLine1.VMLstroke="weight='1pt'; color='blue'; dashstyle='solid';"; MyGraph.Plot(MyLine1); //9904301711 MyLine2.VMLstroke="weight='1pt'; color='red'; dashstyle='solid';"; MyGraph.Plot(MyLine2); //9904301955 divGraphCarleman.innerHTML = MyGraph; spanEqnDocCarleman.innerHTML = "" QGboxb13.value=dbg13; QGboxb14.value=dbg14; return ''; } //function carlemanf4() //9904302010 //function lindata1(ldArg1) //9809281403 function powdata1(ldArg1) //9809291129 { var bgn0=parseFloat(boxcC1.value) var nos0=parseInt(boxcC2.value); //number of steps var end0=parseFloat(boxcC3.value) var pow0=parseFloat(boxcE1.value);//9809291209 if(isNaN(bgn0)) return 'Bgn box value error' if(isNaN(nos0)) return '[# Step] box value error' if(isNaN(end0)) return 'End box value error' if(isNaN(pow0)) return 'Power box value error' if(nos0<=0) return '[# Step] box value <=0' var iter0=0; var i0,i1,i2; var step0=(end0-bgn0)/nos0 var out0=''; i1=bgn0; //if(step0<0)if(pow0>1)pow0=-pow0; //9809291217add/del //because iter0 control while(iter0<=nos0) { iter0++; //out0+=i1+'\n' out0+=Math.pow(i1,pow0)+'\n'; //9809291219 i1=i1+step0; } return out0 } //9809281421 /** //9809261416 //fillRand(ouBoxID) use ".form1." //fillRand2(ouBoxID) delete ".form1." //fillRand3(ouBoxID) delete ".form1." //use chkbxcB1, chkbxcB2 for sorting //fillRand4(ouBoxID) delete ".form1." //output complex number a+i*b 9810121232 //9810121458 use ouBoxID2 //function fillRand4(ouBoxID1,ouBoxID2) //9810121233 //fillRand5(ouBoxID) same as fillRand4 //but isolate code from page elements ID //all page elements ID enter from //function argument list. 9902190914 9902190929 arg1 = 0/1, if 1 output complex, else real arg2 = power index 10^this arg3 = precision output this many digit arg4 = generate this many random numbers arg5 = 0/1 for +/0 [0] or +/0/- [1] arg6 = 0/1 for real [0] or integer [1] all 0/1 '0' is default, '1' must be specified function code nover refer to any html element ID 9902190936 Next is an example of calling method [[ <input type="button" value="random5#" onclick="javascript: QEboxb11.value= fillRand5(0, QEboxcA4.value, QEboxcA3.value, QEboxcA1.value, QEchkbxcA3.checked, QEchkbxcA1.checked); QEboxb12.value= probabOne(QEboxcA1.value); " /> ]] html elements ID all show up at calling line (above example) html elements ID never show up at function code. So that function can be used at other web page. (other web page have different html elements) 2010-02-19-12-13 /**/ function fillRand5(arg1,arg2, arg3,arg4,arg5,arg6) //9902190917 { //arg1=parseInt(arg1); //9902240803 delete //arg2=parseInt(arg2); //arg2 was powIndex=parseFloat(boxcA4.value); //9811211950 arg2=parseFloat(arg2); //9902210800 use parseFloat() arg3=parseInt(arg3); arg4=parseInt(arg4); if( /**isNaN(arg1)|| /*9902240801 delete. Now T/F, not 1/0*/ isNaN(arg2) ||isNaN(arg3)||isNaN(arg4) ) //return 'calling parameter 1/2/3/4 need integers.\n' //9902240802 return 'calling parameter 2/3/4 need integers.\n' +arg1+',' +arg2+',' +arg3+',' +arg4+',' +arg5+',' +arg6 ; //9902191004 var powIndex=arg2; //9902190946 var precision0; precision0=arg3; if(arg6==1)precision0=powIndex; //why 10^0.301=2 not work? //alert('powIndex='+powIndex+'; 9905010632'); //if powIndex=3, stretch random // from [0,1] to [0,1000] powIndex=Math.pow(10,powIndex); var precision1=Math.pow(10,precision0); var randRang=precision1; //if(powIndex)randRang=randRang/powIndex; //9902232247 change to next line //if(powIndex)randRang=randRang/parseInt(powIndex); //9905010634 change to next randRang=randRang/(powIndex); var randPoNe1=1; var randPoNe3=1; var randPN=1; if(arg5)randPN=-1; var dataPerS=arg4; var DecInt=0; if(arg6)DecInt=1; var ouStr1=''; var ouStr2=''; var oneCplx=''; var t0,t1,t2,t3; var dbg0=''; //9902232227 dbg0+='function fillRand5()\narg1 to arg6 are\n' +arg1+',' +arg2+',' +arg3+'\n' +arg4+',' +arg5+',' +arg6+'\n' +'precision1 ='+precision1+', ' +'powIndex='+powIndex+'\n' +'randRang='+randRang+'\n' //control precision. 9902240725 var minus1byteReal=0; var minus1byteImag=0; //alert('use complex? arg1='+arg1+'; 9905011132'); for(t0=0;t0<dataPerS;t0++) { t1=Math.random()*precision1; t3=Math.random()*precision1; dbg0+='*****\n' +'t0 ='+t0+', ' +'t1a='+t1+'\n' +'precision1='+precision1+'\n' /** 2009-10-12-20-00 paid attention that Exercise 2.13 limit to complex number real part be positive. Next check box control complex number real part. complex number imaginary part is +/0/- user can not control. 2009-10-12-20-12 /**/ //control precision. 9902240730 minus1byteReal=0; minus1byteImag=0; if(randPN<0) { t2=(t1+'').charAt((t1+'').length-1); if(t2%2)randPoNe1=-1 else randPoNe1=+1; } t2=(t3+'').charAt((t3+'').length-1); if(t2%2)randPoNe3=-1 else randPoNe3=+1; if(randPoNe1==-1)minus1byteReal=1 if(randPoNe3==-1)minus1byteImag=1 dbg0+='' +'t1b='+t1+', ' +'randPoNe1='+randPoNe1+'\n' +'t1=Math.floor(t1)*randPoNe1='+(Math.floor(t1)*randPoNe1)+'\n' t1=Math.floor(t1)*randPoNe1; t1=t1/randRang; dbg0+='' +'randRang='+randRang+'\n' +'t1=t1/randRang='+t1+'\n' if(DecInt)t1=parseInt(t1); //else t1=bye09(t1); //9902232256 //minus1byteReal //9902240733 change to next , '+1' space for '.' else t1=(''+t1).substring(0,arg3+1+minus1byteReal) //9902232254 include function bye09() //9902240739 delete function bye09(), because //".substring(0,arg3+1+minus1byteReal)" is better. t3=Math.floor(t3)*randPoNe3; t3=t3/randRang; if(DecInt)t3=parseInt(t3); //else t3=bye09(t3); //9902232257 //minus1byteImag //9902240737 change to next [=][][] else t3=(''+t3).substring(0,arg3+1+minus1byteImag) if(arg1) oneCplx='' +t1 +(t3<0?'':'+') +t3+'i'; else oneCplx='' //9902191008 +t1 if(randPoNe1==1)ouStr1+=' '; ouStr1+=oneCplx+'\n'; } //9905010526 delete //QEboxb13.value=dbg0+'9902232241 dbg\n'; //9902232228 return ouStr1; //9902191043 } //9902191108 done fillRand5() //9806101352 function fillRand(ouBoxID) //9809261417 function fillRand2(ouBoxID) //fillRand3(ouBoxID) delete ".form1." //use chkbxcB1, chkbxcB2 for sorting //fillRand4(ouBoxID) delete ".form1." //output complex number a+i*b 9810121232 //--> </script> <br> <a name="sortnumb">&lt;a name="sortnumb"&gt;</a> <font color=red>Sort number</font> not text string <br> <font color=red> Output may contain error, Please verify first. <br> Program environment is MSIE 6.0, please use MSIE </font> <br> <INPUT onclick='javascript:sortNumbMan(0),spanSort1.innerHTML="Output new index for both eigenvalue and vector. Run by sortNumb()"' type=button value="Output New Index"><!--9807151815--> &nbsp; <INPUT onclick='javascript:bubbleMan(0),spanSort1.innerHTML="Output 321 decreasing order."' type=button value="Output 321 New Seq."><!--9807151816--> &nbsp; <INPUT onclick='javascript:bubbleMan(1),spanSort1.innerHTML="Output 123 increasing order."' type=button value="Output 123 New Seq."><!--9905031733--> <br> <span id=spanSort1><font color=red> Sort only numbers. [up side down] for any string. </font></span> <br> <a name="ch01tb04"></a> <table border=0> <tr> <td> Box 11, input number sequence <br> <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("boxc21").value.toString())' type=button value="copy11"> <INPUT onclick='document.getElementById("boxc21").value=""' type=button value="del11"> <INPUT onclick='boxc22.value=upsidedown2(boxc21.value); spanSort1.innerHTML="upside downside reverse. text/number both OK."; ' type=button value="up side down"><!--9905031801--> <br> <TEXTAREA id=boxc21 name=boxc21 rows=6 cols=30 > 0.556 -0.145 0.302e3 -0.305e2 -0.088 </TEXTAREA> </td> <td> Box 12, output answer <br> <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("boxc22").value.toString())' type=button value="copy12"> <INPUT onclick='document.getElementById("boxc22").value=""' type=button value="del12"> <br> <TEXTAREA id=boxc22 name=boxc22 rows=6 cols=30 > </TEXTAREA> </td> </tr> </table> This file sort numbers, if it were sort string, then e2, e3 go wrong. <br> 2009-07-15-11-18 start sortNumb() <br> 2009-07-15-18-40 done sortNumb() <br> 2009-09-29-20-50 done upsidedown() <br> <br> <pre><font size=+2> <a name="docA011">&lt;a name="docA011"&gt;</a> 2009-09-29-15-39 help_1 <a href="#program0">Program</a> Arithmetic Mean and Geometric Mean of a number sequence usage is as following. Box 1 is input. Paste numbers into box 1. Box 2 is output. There are two programs. First AM/GM inequality Second Carleman's inequality <a name="docA012">&lt;a name="docA012"&gt;</a> There are three buttons for them "AM GM 1" it run amgmf1(boxc01.value,1) "Carle man1" it run amgmf1(boxc01.value,2) Above two buttons run function amgmf1() "Carle man2" it run carlemanf2() "Carle man1" read user supplied arbitrary data "Carle man2" create monotone increase/decrease data <a name="docA013">&lt;a name="docA013"&gt;</a> "Carle man1" use Gradual GMed sum <= E*INput sum "Carle man2" drop E=2.718281828459045... for monotone increase data change E to a value less than one, for example 0.9, still perfect. Gradual GMed sum <= 0.9*INput sum for monotone decrease data need E to rise input data sum over Gradual GMed sum. "Carle man2" main purpose is to see the ratio of Gradual GMed sum / INput sum (no E here) <script language="javascript">alert0()</script> <a name="docA014">&lt;a name="docA014"&gt;</a> There are four debug checkbox. dbg a,b,c;d. "AM GM 1" do not use debug checkbox "Carle man1" use dbg a,b,c three checkbox "Carle man2" use dbg d one checkbox If check box are unchecked. Output less material and run faster for shorter information. If check box are checked. Output more material and run slower for detail information. "dbg" button is all-clear button, not all-check. <a name="docA015">&lt;a name="docA015"&gt;</a> dbg a checked, "Carle man1" output input sequence and gradual GMed number sequence. dbg b checked, "Carle man1" output carlrite that is input sequence related output. include echo print input sequence, make sure program read right data. dbg c checked, "Carle man1" output carlleft include carlpart, carlpart is long string debug data. dbg d checked, "Carle man2" output longer output. <a name="docA016">&lt;a name="docA016"&gt;</a> ± box and É box are add for "Carle man1" use. If ± box fill a number 0<=alpha<=1/log(2)=1.4426950408889633 "Carle man1" use alpha to lower input sum reference is next [[ 2009-09-02-22-06 LiuHH access http://www.emis.de/journals/JIPAM/images/029_00_JIPAM/029_00_www.pdf page 9/10 theorem 3.2 ]] <a name="docA017">&lt;a name="docA017"&gt;</a> É box has no theory base. É simply add to right hand side of Gradual GMed sum <= E*INput sum as Gradual GMed sum <= É*E*INput sum If set É=1/E=0.36787944117144233 then equation become Gradual GMed sum <= INput sum Check box 1/E fill 1/E=0.36787944117144233 for you. <a name="docA018">&lt;a name="docA018"&gt;</a> The remaining boxes/buttons create data for you. "equal #" create equal numbers. It take number from "10^" box and repeat fill-box times. output to box 1 as input data. "random#" create random numbers. "10^" box determine random number order of magnitude. "+/0" box checked, output positive/zero random numbers. "+/0/-" box checked, output +/0/- random numbers. "digits" box determine the length of each random number. "fill" box determine build how many random number. "integer" checkbox force output integer. "123" checkbox sort random number to increase order. "321" checkbox sort random number to decrease order. <a name="docA019">&lt;a name="docA019"&gt;</a> "powData" button create x^power data. "bgn" box is begin value. "# Step" box determine how many step to divide. "End" box determine stop value. "power" box determine power in x^power. If set same value to "bgn" box "End" box output constant data. "Carle man2" button automatically click "powData" button and read data. This is designed for you to build random data or build power data, and not necessary to use data here. You can build data and copy box1 value, use data in other application. <a name="docA020">&lt;a name="docA020"&gt;</a> Box11 and box12 has nothing to do with AMGM or Carleman inequality. Program ("123", "321") use function bubble_1(). Add few more line, build box11,12, let you to sort number. A handy tool. 2009-09-29-16-32 stop <a name="docA021">&lt;a name="docA021"&gt;</a> 2009-09-29-20-58 start 2009-09-29 add "upside down" function. Purpose is to reverse increase/decrease numbers. Text (non-number) can be reversed too. "123", "321" checkbox care only this program generated data. If you have your own increase/decrease data and want to reverse them, "123", "321" checkbox can not help. "up side down" button will help you with your data. 2009-09-29-21-02 stop <a name="docA022">&lt;a name="docA022"&gt;</a> 2009-09-29-21-10 start Alert !! Both Arithmetic Mean and Geometric Mean inequality and Carleman inequality work with positive or zero number only. This page allow you to create sequence contain negative number. You can create number sequence here and use them in other place. If you use number sequence right here for AM/GM or Carleman inequalities, <font color=red>it is your responsibility not to generate negative number!</font> 2009-09-29-21-15 stop <a name="docA023">&lt;a name="docA023"&gt;</a> 2009-09-30-07-33 start On 2009-09-30-00-51 write function carlemanf3() The button is "Carle man3". Main point is to involve sum of Gradual AMed sequence. Define IN = sum of INput sequence GA = sum of Gradual AMed sequence GG = sum of Gradual GMed sequence Carleman's inequality in brief is GG<=E*IN Many test show GG/IN far below E=2.718281828459045... Carleman3 show GA/IN still below E=2.718281828459045... (AM >= GM, therefore GA/IN >= GG/IN ) carlemanf3() output INput sequence Gradual AMed sequence Gradual GMed sequence and sum each, find GG/IN GA/IN two ratio. function carlemanf3() help thinking. 2009-09-30-07-41 stop <a name="docA024">&lt;a name="docA024"&gt;</a> 2009-09-30-08-03 start If you have a set test data pasted to box 1. Click "Carle man1", program read your data. Click "Carle man3", program read your data. But Click "Carle man2", your input data changed you may be surprised and wondering what is going on? "Carle man2" button read data from "powData" related data, Bgn box, # Step box, End box, power box all contribute to "Carle man2" button. "powData" generated data send to box 1 and erase previous value. "Carle man2" button main point is to test monotone increase or monotone decrease data. <font color=red>If your data is not generated from "powData" button do not touch "Carle man2" button.</font> 2009-09-30-08-12 stop <a name="docA025">&lt;a name="docA025"&gt;</a> 2009-10-05-12-36 start Update 2009-10-05 correct GM error. nineth draft and before tute0012a09.htm output GM correct. tenth draft and after tute0012a10.htm output GM wrong. <a name="docA026">&lt;a name="docA026"&gt;</a> correct code is [[ j1=1/len0; for(j0=0;j0&lt;len0;j0++) { am0+=inp0[j0]/len0; gm0*=Math.pow(inp0[j0],j1); //9809261046 } ]] <a name="docA027">&lt;a name="docA027"&gt;</a> wrong code is [[ j1=1/len0; spanAlert1.innerHTML=''; //9809291518 j1=0; for(j0=0;j0&lt;len0;j0++) { if(inp0[j0]&lt;0)j1=1; //9809291521 am0+=inp0[j0]/len0; gm0*=Math.pow(inp0[j0],j1); //9809261046 } if(j1==1) spanAlert1.innerHTML='' //9809291518 +'&lt;font color=red&gt;ALERT ! box1 has negative number! AMGM do not treat negative!&lt;/font&gt;' ; ]] <a name="docA028">&lt;a name="docA028"&gt;</a> wrong code re-use j1 for different purpose. for three element sequence q3=[1,3,9] its GM = (1*3*9)^(1/3) = 27^(1/3) = 3 correct code assign j1=1/len0; that is j1=1/3 use j1 in gm0*=Math.pow(inp0[j0],j1); //9809261046 get correct answer. Wrong code change j1 definition to j1=0 then gm0*=Math.pow(inp0[j0],j1); is gm0*=Math.pow(inp0[j0],0); always get 1, wrong. <a name="docA029">&lt;a name="docA029"&gt;</a> On 2009-09-29-15-?? LiuHH add code to warn negative value element. The flag used is again j1 (here wrong!!), j1 is redefined. Because GM answer is already correct, LiuHH pay attention to correct warning, and forget to check GM answer. <a name="docA030">&lt;a name="docA030"&gt;</a> 2009-10-05-11-18 found GM answer is wrong! read code, find out the redefinition error. change j1=1/len0; gm0*=Math.pow(inp0[j0],j1); //9809261046 to gmPow=1/len0; gm0*=Math.pow(inp0[j0],gmPow); //9810051143 solve problem 2009-10-05-12-52 stop </font></pre> <hr> <pre><font size=+2><a name="ch02b001">&lt;a name="ch02b001"&gt;</a> 2009-10-01-11-49 start  %0Carleman warm up <script language="javascript">alert0()</script> <!--2009-10-01-19-36 start--><font color=red> Carleman's Inequality require input sequence has infinite many elements and sum to finite value. Only monotone decreasing sequence can be a candidate of Carleman's Inequality seq. <!--2009-10-01-19-39 stop--></font> <a href="#textbook">Text book</a> page 27 discuss Carleman's Inequality. For each positive real sequence a<sub>1</sub>, a<sub>2</sub>, ... a<sub>k</sub>, one has next inequality. </font></pre> <a name="ch02b002">&lt;a name="ch02b002"&gt;</a> <br> <TABLE WIDTH="380" id=T027L14a border=0 ><!--9810011154--> <TR> <TD> &nbsp; </TD> <TD> <TABLE WIDTH="260" border=0 id=T027L14b > <TR> <TD> <CENTER><FONT SIZE=-2>k="</FONT></CENTER> <CENTER><FONT SIZE=+3>"</FONT></CENTER> <CENTER><FONT SIZE=-2>k=1</FONT></CENTER> </TD> <TD> (a<sub>1</sub>a<sub>2</sub>...a<sub>k</sub>)<sup>1/k</sup> </TD> <TD> f" e </TD> <TD> <CENTER><FONT SIZE=-2>k="</FONT></CENTER> <CENTER><FONT SIZE=+3>"</FONT></CENTER> <CENTER><FONT SIZE=-2>k=1</FONT></CENTER> </TD> <TD> a<sub>k</sub> </TD> </TR> </TABLE> </TD> <TD> ---page 27 <br> ---eqn.2.15 </TD> </TR> </TABLE> where e=2.718281828459045... <br> width of above equation <INPUT name=Button027L14a type="button" value="default" onclick="B027L14a.value=380,B027L14b.value=260,T027L14a.width=B027L14a.value,T027L14b.width=B027L14b.value"> <input id="B027L14a" value=380 size=3 onchange=T027L14a.width=B027L14a.value /> <input id="B027L14b" value=260 size=3 onchange=T027L14b.width=B027L14b.value /> <pre><font size=+2><a name="ch02b003">&lt;a name="ch02b003"&gt;</a> 2009-10-01-12-03 here Problem statement exclude a<sub>k</sub>=0 and not allow a<sub>k</sub><0 . One online page [[ 2009-09-02-22-06 LiuHH access http://www.emis.de/journals/JIPAM/images/029_00_JIPAM/029_00_www.pdf carleman-029_00_JIPAM-029_00_www.pdf page 3/10 introduction ]] say equality in <a href="#ch02b002">eqn.2.15</a> hold if and only if one element of sequence is zero. <a name="ch02b004">&lt;a name="ch02b004"&gt;</a> First time see <a href="#ch02b002">eqn.2.15</a> , LiuHH is wondering what is the meaning of this equation? After re-read <a href="tute0012.htm#textbook">textbook</a> several times, gradually understand that eqn.2.15 right hand side is sum of original input sequence eqn.2.15 left hand side is sum of gradual GMed new sequence from original input seq. <a name="ch02b005">&lt;a name="ch02b005"&gt;</a> To explain clearly, let k=1 to k=5 (was k=inf) original input sequence is a<sub>1</sub>,a<sub>2</sub>,a<sub>3</sub>,a<sub>4</sub>,a<sub>5</sub> When first term goto front stage, we have first original term a<sub>1</sub> ---eqn.AF001 first gr. GMed term (a<sub>1</sub>)^(1/1) ---eqn.AF002 When first two terms goto front stage, we have second original term a<sub>2</sub> ---eqn.AF003 second gr. GMed term (a<sub>1</sub>*a<sub>2</sub>)^(1/2) ---eqn.AF004 <font color=red>eqn.AF003 no a<sub>1</sub> shadow, eqn.AF004 a<sub>1</sub> has influence. </font> <a name="ch02b006">&lt;a name="ch02b006"&gt;</a> When first three terms goto front stage, we have third original term a<sub>3</sub> ---eqn.AF005 third gr. GMed term (a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>)^(1/3) ---eqn.AF006 <font color=red>eqn.AF005 no a<sub>1</sub>,a<sub>2</sub> shadow, eqn.AF006 a<sub>1</sub>,a<sub>2</sub> have influence etc. </font> When first four terms goto front stage, we have fourth original term a<sub>4</sub> ---eqn.AF007 fourth gr. GMed term (a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>*a<sub>4</sub>)^(1/4) ---eqn.AF008 When all five terms goto front stage, we have fifth original term a<sub>5</sub> ---eqn.AF009 fifth gr. GMed term (a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>*a<sub>4</sub>*a<sub>5</sub>)^(1/5) ---eqn.AF010 <a name="ch02b007">&lt;a name="ch02b007"&gt;</a> Carleman's Inequality sum both original sequence and gradual GMed new sequence, result is Sum of original seq. a<sub>1</sub>+a<sub>2</sub>+a<sub>3</sub>+a<sub>4</sub>+a<sub>5</sub> ---eqn.AF011 (extend to infinite many elements for Carleman) Sum of gr. GMed seq. ---eqn.AF012 (a<sub>1</sub>)^(1/1) + (a<sub>1</sub>*a<sub>2</sub>)^(1/2)+(a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>)^(1/3) +(a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>*a<sub>4</sub>)^(1/4)+(a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>*a<sub>4</sub>*a<sub>5</sub>)^(1/5) (extend to infinite many elements for Carleman) <a name="ch02b008">&lt;a name="ch02b008"&gt;</a> re-write Sum of original seq. eqn.AF011 and sum of gr. GMed seq. eqn.AF012 in compact form and Carleman demand that the ratio of GMed sum / original sum not exceed E=2.718281828459045... then we get <a href="#ch02b002">eqn.2.15</a> Carleman's Inequality push this sequence to infinity. 2009-10-01-12-36 here <a name="ch02b009">&lt;a name="ch02b009"&gt;</a><a href='http://freeman2.com/tute0012.htm#ch02b009'>  %0</a>Gradual GMed seq. sum Follow the same pattern, we can create gradual AMed sequence as following <font color=red> Define IN</font> = sum of INput sequence IN = eqn.AF011 <font color=red> Define GG</font> = Gradual GMed seq. sum GG = eqn.AF012 <a name="ch02b010">&lt;a name="ch02b010"&gt;</a>  %0Gradual AMed seq. sum <font color=red>Define GA</font> = eqn.AF013 Gradual AMed seq. sum = ---eqn.AF013 (a<sub>1</sub>)/1 + (a<sub>1</sub>+a<sub>2</sub>)/2 + (a<sub>1</sub>+a<sub>2</sub>+a<sub>3</sub>)/3 +(a<sub>1</sub>+a<sub>2</sub>+a<sub>3</sub>+a<sub>4</sub>)/4 + (a<sub>1</sub>+a<sub>2</sub>+a<sub>3</sub>+a<sub>4</sub>+a<sub>5</sub>)/5 Because AM >= GM , each individual term of gr. AMed seq. >= each individual term of gr. GMed seq. then we know GA >= GG ---eqn.AF014 <a name="ch02b011">&lt;a name="ch02b011"&gt;</a> Carleman proved if multiply <a href="#ch02b009">IN</a> by E=2.718281828459045... then GG <= E*IN ---eqn.AF015 is guaranteed. Above introduce background information. Hope you will get better picture now. 2009-10-01-12-51 here <script language="javascript">alert0()</script> <a name="ch02b012">&lt;a name="ch02b012"&gt;</a>  %0GG and GA but not Carleman 2009-10-01-13-58 start Carleman's inequality is GG <= E*IN Input sequence must be infinite many elements and elements summation is finite value. <font color=red><!--9810011950--> The following is NOT Carleman's inequality. Because discuss finite many elements Because discuss monotone increase sequence. </font> Is it always need an 'E*' to rise '<a href="#ch02b009">IN</a>'. Whether there is case that GG <= IN ? without 'E*' ! (E=2.718281828459045...) Let us find answer for the simplest case two number sequence S2 = [a<sub>1</sub>, a<sub>2</sub>] <a name="ch02b013">&lt;a name="ch02b013"&gt;</a> If a<sub>1</sub>=a<sub>2</sub> ---eqn.AF016 then IN = sum of INput sequence = a<sub>1</sub>+a<sub>2</sub> = 2*a<sub>1</sub> GG = Gradual GMed seq. sum = (a<sub>1</sub>)^(1/1) + (a<sub>1</sub>*a<sub>2</sub>)^(1/2) = (a<sub>1</sub>) + (a<sub>1</sub>*a<sub>1</sub>)^(1/2) = 2*a<sub>1</sub> ---eqn.AF017 If a<sub>1</sub>=a<sub>2</sub> IN = GG we do not need 'E*' between <a href="#ch02b009">IN</a> and GG <a name="ch02b014">&lt;a name="ch02b014"&gt;</a> If a<sub>1</sub> < a<sub>2</sub> ---eqn.AF018 that is if sequence is increasing. IN = sum of INput sequence = a<sub>1</sub>+a<sub>2</sub> ---eqn.AF019 GG = Gradual GMed seq. sum = (a<sub>1</sub>)^(1/1) + (a<sub>1</sub>*a<sub>2</sub>)^(1/2) ---eqn.AF020 <a name="ch02b015">&lt;a name="ch02b015"&gt;</a> Now consider their difference IN = a<sub>1</sub> + <font color=red>a<sub>2</sub> </font> ---eqn.AF019 GG = a<sub>1</sub> + <font color=red>(a<sub>1</sub>*a<sub>2</sub>)^(1/2)</font> ---eqn.AF020 Because (a<sub>1</sub>*a<sub>2</sub>)^(1/2) is geometric mean between a<sub>1</sub> and a<sub>2</sub> <a name="ch02b016">&lt;a name="ch02b016"&gt;</a> For an increasing sequence a<sub>1</sub> < a<sub>2</sub> (a<sub>1</sub>*a<sub>2</sub>)^(1/2) < a<sub>2</sub> then GG < <a href="#ch02b009">IN</a> For a decreasing sequence a<sub>1</sub> > a<sub>2</sub> (a<sub>1</sub>*a<sub>2</sub>)^(1/2) > a<sub>2</sub> then GG > IN <a name="ch02b017">&lt;a name="ch02b017"&gt;</a> Consider a simple numerical example Increase sequence [1, 2, 3] IN = 1+2+3 GG = 1 + (1*2)^(1/2) + (1*2*3)^(1/3) = 1 + 1.414213562373095 + 1.8171205928321396 IN = 6 GG = 4.231334155205235 GG < IN and GG << E*IN (E=2.718281828459045) <a name="ch02b018">&lt;a name="ch02b018"&gt;</a>  %0monotone increase, GG < IN For a monotone increase sequence, we conclude that we do not need 'E*' and Gradual GMed sequence sum < INput sequence sum For a monotone decrease sequence, the condition is reversed, in general Gradual GMed sequence sum > INput sequence sum <a name="ch02b019">&lt;a name="ch02b019"&gt;</a> Consider a simple numerical example Decrease sequence [3, 2, 1] <a href="#ch02b009">IN</a> = 3+2+1 GG = 3 + (3*2)^(1/2) + (3*2*1)^(1/3) = 3 + 2.4494897427831783 + 1.8171205928321396 IN = 6 GG = 7.266610335615319 GG > IN and GG < E*IN (E=2.718281828459045) <font color=red><!--9810011956--> Above is NOT Carleman's inequality. Because discuss finite many elements Because discuss monotone increase sequence. </font> 2009-10-01-14-48 stop <a name="ch02b020">&lt;a name="ch02b020"&gt;</a>  %0Order critical for GA and GG 2009-10-02-14-28 start Restate above mentioned monotone increase sequence and monotone decrease sequence in a slightly different way. Assume we have a sequence Q1=[1,4,3,5,2] ---eqn.AF021 Put Q1 in monotone increase order get Q2=[1,2,3,4,5] ---eqn.AF022 Put Q1 in monotone decrease order get Q3=[5,4,3,2,1] ---eqn.AF023 <a name="ch02b021">&lt;a name="ch02b021"&gt;</a> If order is not important, then Q1, Q2 and Q3 are the same. For example: sum SUM Q1<sub>i</sub>=1+4+3+5+2=15 ---eqn.AF024A SUM Q2<sub>i</sub>=1+2+3+4+5=15 ---eqn.AF024B SUM Q3<sub>i</sub>=5+4+3+2+1=15 ---eqn.AF024C Above is sequence element sum <a name="ch02b022">&lt;a name="ch02b022"&gt;</a> Below is Gradual Geometric_Mean_ed sum first gr. GMed term (a<sub>1</sub>)^(1/1) ---eqn.AF002 second gr. GMed term (a<sub>1</sub>*a<sub>2</sub>)^(1/2) ---eqn.AF004 third gr. GMed term (a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>)^(1/3) ---eqn.AF006 ..... k th gr. GMed term (a<sub>1</sub>*a<sub>2</sub>*...*a<sub>k</sub>)^(1/k) ---eqn.AF025 Can you see if Q1, Q2, Q3 produce same result or different result for Gradual GMed sum ? <a name="ch02b023">&lt;a name="ch02b023"&gt;</a> Sum of input sequence eqn.AF024 each term do not have memory about earlier term value. BUT, Gradual GMed sum has memory from earlier term. For example if sequence is monotone decrease, then a<sub>1</sub> has largest value, this value influence the following terms all the way to the end. Create a high value Gradual GMed sum. On the other hand, if sequence is monotone increase, everything reverse. <a name="ch02b024">&lt;a name="ch02b024"&gt;</a><font color=red> For Gradual Geometric_Mean_ed sum, order of input sequence is very important. For Gradual Arithmetic_Mean_ed sum, same thing. </font> 2009-10-02-15-04 stop <a name="ch02b025">&lt;a name="ch02b025"&gt;</a>  %0Begin textbook chapter two, Carleman 2009-10-02-15-10 start Above is general reading understanding. Below is <a href="#textbook">textbook</a> page 27, chapter two Carleman's inequality. For each positive real sequence a<sub>1</sub>, a<sub>2</sub>, ... a<sub>k</sub>, one has next inequality. </font></pre> <a name="ch02b026">&lt;a name="ch02b026"&gt;</a> <br> <TABLE WIDTH="380" id=T027L14c border=0 ><!--9810021513--> <TR> <TD> &nbsp; </TD> <TD> <TABLE WIDTH="260" border=0 id=T027L14d > <TR> <TD> <CENTER><FONT SIZE=-2>k="</FONT></CENTER> <CENTER><FONT SIZE=+3>"</FONT></CENTER> <CENTER><FONT SIZE=-2>k=1</FONT></CENTER> </TD> <TD> (a<sub>1</sub>a<sub>2</sub>...a<sub>k</sub>)<sup>1/k</sup> </TD> <TD> f" e </TD> <TD> <CENTER><FONT SIZE=-2>k="</FONT></CENTER> <CENTER><FONT SIZE=+3>"</FONT></CENTER> <CENTER><FONT SIZE=-2>k=1</FONT></CENTER> </TD> <TD> a<sub>k</sub> </TD> </TR> </TABLE> </TD> <TD> ---page 27 <br> ---eqn.2.15 </TD> </TR> </TABLE> where e=2.718281828459045... <br> width of above equation <INPUT name=Button027L14c type="button" value="default" onclick="B027L14c.value=380,B027L14d.value=260,T027L14c.width=B027L14c.value,T027L14d.width=B027L14d.value"> <input id="B027L14c" value=380 size=3 onchange=T027L14c.width=B027L14c.value /> <input id="B027L14d" value=260 size=3 onchange=T027L14d.width=B027L14d.value /> <pre><font size=+2><a name="ch02b027">&lt;a name="ch02b027"&gt;</a> 2009-10-02-15-21 here eqn.2.15 right hand side is the summation of input sequence a<sub>1</sub>+a<sub>2</sub>+a<sub>3</sub>+...+a<sub>k</sub> ---eqn.AF027 multiply by e=2.718281828459045... eqn.2.15 left hand side is the summation of Gradual GMed terms of input sequence. Explicit form is (a<sub>1</sub>)^(1/1)+(a<sub>1</sub>*a<sub>2</sub>)^(1/2)+(a<sub>1</sub>*a<sub>2</sub>*a<sub>3</sub>)^(1/3)+ ... +(a<sub>1</sub>*a<sub>2</sub>*...*a<sub>k</sub>)^(1/k) ---eqn.AF028 <a name="ch02b028">&lt;a name="ch02b028"&gt;</a><font color=red> Carleman's inequality treat infinite long sequence, number of terms in a<sub>k</sub> sequence is infinity many. Require SUM{a<sub>k</sub>} be finite.</font> Then for large k, a<sub>k</sub> must be monotone decrease. When k approach to infinity, a<sub>k</sub> approach to zero. <a href="#ch02b002">eqn.2.15</a> suggest if SUM{a<sub>k</sub>} be finite, then SUM{(a<sub>1</sub>*a<sub>2</sub>*...*a<sub>k</sub>)^(1/k)} be finite too. <hr> <a name="docB001">&lt;a name="docB001"&gt;</a> <a href="#clickCarleman">click</a> <a href="tute0041.htm#ch11b070">11.4</a> <a href="tute0041.htm#ch11b115">doc2</a> 2010-05-03-16-56 start This file (<a href=carleman.htm#clickCarleman>local</a>)<a href=http://freeman2.com/carleman.htm#clickCarleman> http://freeman2.com/carleman.htm</a> is written when read (CSMC)<a href=http://www-stat.wharton.upenn.edu/~steele/Publications/Books/CSMC/CSMC_index.html> The Cauchy-Schwarz Master Class</a> chapter 11 page 174 & 175. Text main point is proof //<a href=tute0041.htm#ch11b077>two eqns</a> from Carleson ineq. to Carleman inequality. Partial document is <a href=tute0041.htm#ch11b115>here</a>. <a name="docB002">&lt;a name="docB002"&gt;</a> carleman.htm control panel has the following arrangement. Brief explanation after every function. [[ Main click button is here. Click 'rand5' first, then click 'C'. Box 1 input Calculator local Carleman's inequality require input sequence infinite sum be bounded. ]] <a name="docB003">&lt;a name="docB003"&gt;</a> Box 1 let user input his data for drawing. Carleson require data be from great value to small value. All data be positive. Because there is log operation. If your data is in random order, you can sort your data at <a href="#sortnumb">Box 11</a> Paste data to Box 11, click [Output 321 New Seq] button. or [Output 123 New Seq] button. Output at Box 12. <a name="docB004">&lt;a name="docB004"&gt;</a> [Output New Index] button output sequence index, programmer can re-order both eigenvalue and eigen vector. New Index is decrease order. 2010-05-03-17-21 stop <a name="docB005">&lt;a name="docB005"&gt;</a> <a href="#clickCarleman">click</a> <a href="tute0041.htm#ch11b070">11.4</a> <a href="tute0041.htm#ch11b115">doc2</a> 2010-05-03-18-23 start [[ x min: , x max: ; y min: , y max: ; Drawing board size W: H: complex ]] <a name="docB006">&lt;a name="docB006"&gt;</a> Above two lines let user decide x-axis/y-axis upper/lower bounds and drawing board size . complex check box is provided let user create complex random number use at OTHER web page/application. Complex output no sort. <a name="docB007">&lt;a name="docB007"&gt;</a> [[ [AM GM 1] [Carleman 1] [Carleman 2] [Carleman 3] [dbg] a,b,c;d ]] <a name="docB008">&lt;a name="docB008"&gt;</a> [AM GM 1] read data from Box 1 calculate Arithmetic Mean and Geometric Mean for Box 1 data calculate total sum and total production value for Box 1 data Output to Box 2 <a name="docB009">&lt;a name="docB009"&gt;</a> [Carleman 1] read data from Box 1, calculate <a href=/tute0041.htm#ch11b078>Carleman</a> equation value and report at box 2 as [[ carlleft <= carlrite answer is next 7.096572451715854<=14.270979599409987 ]] <a name="docB010">&lt;a name="docB010"&gt;</a> <a href="#clickCarleman">click</a> <a href="tute0041.htm#ch11b070">11.4</a> <a href="tute0041.htm#ch11b115">doc2</a> [Carleman 2] build data from [[ [powData] Bgn 100 ,# Step 99 ,End 1 power 1.2 ]] save data to box 1 as input. User can not control box 1 value. User can control [powData] parameters Bgn 100 ,# Step 99 ,End 1, power 1.2 Output to box 2. Hope see sumgm/sumin ratio approach E=2.718281828459045 <a name="docB011">&lt;a name="docB011"&gt;</a> Remind: Carleman's inequality is "gradual_GMed_seq. f" e* "input_seq. therefore "gradual_GMed_seq. / "input_seq. f" e <a name="docB012">&lt;a name="docB012"&gt;</a> [Carleman 3] read data from Box 1, Output three sequences INput sequence Gradual AMed sequence Gradual GMed sequence 2010-05-03-18-49 here <a name="docB013">&lt;a name="docB013"&gt;</a> [[ [dbg] a,b,c;d ]] is for debug purpose. Please see <a href="#docA015">docA015</a> ± box please see <a href="#docA016">docA016</a> É box and '1/E' please see <a href="#docA017">docA017</a> <a name="docB014">&lt;a name="docB014"&gt;</a> [[ ¡% 123 , ¡% 321 [equal#] 10^[.7] ; ¡% +/0 , ¡% +/0/- ; [8]digits [rand5] fill [12] numbers; integer; ]] If check ¡% 123 box and click [rand5] output random number in increase order (123) to box 1, red curve shape m%n%. If check ¡% 321 box and click [rand5] output random number in decrease order (321) to box 1, red curve shape p%o%. ¡% +/0 output non-negative number ¡% +/0/- output +/0/- number. <a name="docB015">&lt;a name="docB015"&gt;</a> <a href="#clickCarleman">click</a> <a href="tute0041.htm#ch11b070">11.4</a> <a href="tute0041.htm#ch11b115">doc2</a> If 10^[.7] and fill [12] numbers, then click [equal#], program output 12 constant numbers .7 to box 1 <a name="docB016">&lt;a name="docB016"&gt;</a> [[ Above is random number. Output to box 1 above. Below is equal space number. Output to box 1 above. [powData] Bgn [100] ,# Step [99] ,End [1] power [1] Set to 1 to get what you expected. If set power to -2, all output number raise to power -2 "[k=1,"]1/k2=À2/6=1.64493406684... " [2] N " ]] <a name="docB017">&lt;a name="docB017"&gt;</a> Generated random number are not equal spaced. Program has [powData] button. Output numbers are equal spaced if set power to 1 <a name="docB018">&lt;a name="docB018"&gt;</a> If set Bgn [100] ,# Step [99] ,End [1], power [1] and click [powData] , program output to box 1 the value "100 99 98 ... 1" "[k=1,"]1/k^2=À^2/6=1.64493406684... give an example for power [-2] Euler solved this problem. <a name="docB019">&lt;a name="docB019"&gt;</a> Button """ give answer of the total sum of data in box 1. Button [2] "N" give answer of 2-norm of data in box 1. Button """ give answer of the total product of data in box 1. """ and """ answer can be found from [AM GM 1] button. 2010-05-03-19-18 stop <a name="docB020">&lt;a name="docB020"&gt;</a> <a href="#clickCarleman">click</a> <a href="tute0041.htm#ch11b070">11.4</a> <a href="tute0041.htm#ch11b115">doc2</a> 2010-05-03-19-57 start [[ Box 2 Sum(log(1/a_i)) Calculator local ]] Box 2 is output for most button. The mark "Sum(log(1/a_i))" target at Problem 11.4 from Carleson to Carleman Problem 11.4 output "Sum(log(1/a_i))" <a name="docB021">&lt;a name="docB021"&gt;</a> "Calculator" link to calculator page "local" link to local page. "Calculator" access online page http://freeman2.com/complex2.htm#calculator "local" access (if you are off line) file:///C:/download/freeman2/complex2.htm#calculator <a name="docB022">&lt;a name="docB022"&gt;</a> If you save a copy of complex2.htm and you save a copy of carleman.htm to "C:\download\freeman2\" folder then click "local" is effective. <a name="docB023">&lt;a name="docB023"&gt;</a> [[ A=Gradual GM; B=Sum(log(1/a_i)); C both; D for fig.11.2 Carleman [A] [B] [rand5] [C] [pow] [wipe] [D]0ControlCenter Please fill in your data to box 1 or click rand5, then click [C]. ]] Above is new to carleman.htm. If you have your own data, paste your data to box 1 and click [C] <a name="docB024">&lt;a name="docB024"&gt;</a> <a href="#clickCarleman">click</a> <a href="tute0041.htm#ch11b070">11.4</a> <a href="tute0041.htm#ch11b115">doc2</a> If you do not have data, click [rand5] to generate random data to box 1 and click [C] to draw. [A] draw Gradual GMed sequence [B] draw Sum(log(1/a_i)) curve [C] draw both [A] and [B] [D] draw a polygon like fig.11.2 [A] [B] [C] read data from box 1 <a name="docB025">&lt;a name="docB025"&gt;</a> [D] build data save to box 1. [D] erase your data in box 1. [rand5] build random data to box 1. [pow] build power data to box 1. [wipe] erase figure. <a name="docB026">&lt;a name="docB026"&gt;</a> Program default check "321" and build decrease order numbers. If you uncheck "321" and if you uncheck "123" at same time then click [rand5] and [C] buttons program output random-order random number. The drawing is not convex and not concave. Curve look like stock market index, run wild. <a name="docB027">&lt;a name="docB027"&gt;</a> Javascript generate random number in the range [0,1]. Program change random number range upper bound based upon "10^[2]" box value. Default "10^[0.301]" for 10^0.301=2 If random number in [0,2], half be greater than 1, half be less than. <a name="docB028">&lt;a name="docB028"&gt;</a> Data=1 is where slope=0 Æ'(x)=log(1/a<sub>n</sub>) ---<a href='tute0041.htm#ch11b083'>eqn.BI039</a> Æ'(x)=log(1/1)=0 If you change from "10^[0.301]" to "10^[0.]" and click [C], red curve go up. If you change from "10^[0.301]" to "10^[2]" and click [C], red curve go down. <a name="docB029">&lt;a name="docB029"&gt;</a> <a href="#clickCarleman">click</a> <a href="tute0041.htm#ch11b070">11.4</a> <a href="tute0041.htm#ch11b115">doc2</a> It is better to read <a href="tute0041.htm#textbook">textbook</a> and do experiment at this page. Thank you for visiting Freeman's web page. Freeman (Liu,Hsinhan) 2010-05-03-20-38 stop </font></pre> <hr><br> Javascript index <br> <a href=http://freeman2.com/jsindex2.htm> http://freeman2.com/jsindex2.htm </a> &nbsp; <a href=jsindex2.htm> local </a> <!--9810201450 add local link--> <br> Save graph code to same folder as htm files. <br> <a href=http://freeman2.com/jsgraph2.js> http://freeman2.com/jsgraph2.js </a> &nbsp; <a href=jsgraph2.js> local </a> <br> <script src="jslist1e.js" language="javascript"></script> <br> <br> This page, Carleman Inequality program <br> <a href=http://freeman2.com/carleman.htm> http://freeman2.com/carleman.htm </a> <br> First upload 2010-05-04 <br> carleman.htm was part of <a href=http://freeman2.com/tute0012.htm#program0> tute0012.htm </a> <br> <br> Thank you for visiting Freeman's page.0 <br> Freeman 02010-05-03-20-48 <br><br> <span id="tuteLink2"></span> </BODY> </HTML> <script language="javascript" type="text/javascript"> <!-- /** 2009-06-12-15-31 start Javascript use float number for calculation. Answer may contain long string of '000000' or '999999', for example 2.00000000000001 -25.999999999999996 On 2009-06-12-11-58 write a function function bye09(in09) //9806121158 To use this function, call as following coef2=bye09(coef2); where coef2 is a number. After call 2.00000000000001 change to 2 -25.999999999999996 change to -26 It is handy, you can use it too. If number is 1.23111111111 there is no change. function bye09(in09) handle output number for better looking. Do not call bye09() during calculation, that is just slow down process. If expect answer to be irrational Do not call bye09(). If expect answer to be integer or short decimal number like 1.2. In these case you can call bye09(). 2009-06-12-15-40 stop 2009-06-17-19-05 bye09() process only one number at a time. If you have a string of several numbers. Do not put number string as input argument bye09() will send string back immediately. This file has sample code at time stamp '9806171858' 2009-06-17-19-09 stop /**/ function bye09(in09) //9806121158 { // in09 is input number, // for example 2.0000000001 // If input is not a number, return here if(isNaN(in09)) return in09; // where is decimal point '.' ? var dotLoc=(in09+'').indexOf('.',0); // no decimal point? integer? return. if(dotLoc==-1) return in09; // change input string to number in09=parseFloat(in09); // if number has '000000' ÿ var zeroLoc=(in09+'').indexOf('000000',dotLoc); // find '000000' ÿcut start '000000' if(zeroLoc>0) //9806121216 return parseFloat((in09+'').substring(0,zeroLoc)); //9806121209 // if number has '999999' ÿ var nineLoc=(in09+'').indexOf('999999',dotLoc); // find '999999' ÿ cut start '999999' if(nineLoc>0) //9806121223 here { // copy number left to '999999' //but immediately neighbor digit not copy // nineLoc-1 because '999999' need increase // digit by one. //If input is 1.23999999999 copy only 1.2 //not copy 1.23 , because 3 will change to 4. var nine0=(in09+'').substring(0,nineLoc-1); //between '.' and '999999' has other digit. if(nineLoc-dotLoc>1) //9806121220 { //neighbor digit add one, paste to end nine0+=(parseInt((in09+'').charAt(nineLoc-1))+1); } else //between '.' and '999999' no other digit. {// modified number is an integer nine0=parseInt(nine0); //9806121313 if(nine0<0)nine0--; // negative integer minus one else nine0++; //9806121314 positive integer add one } return parseFloat(nine0); //9806121213 return new number } // no '000000' no '999999' return original form return parseFloat(in09); //9806121224 } //function bye09(in09) function stndrdth(i0) //9802141617 begin js code { var sth = [" ", "st", "nd", "rd", "th"]; if(i0<0) return sth[0]; if(i0%100>3&&i0%100<21) return sth[4]; if(i0%10==1) return sth[1]; if(i0%10==2) return sth[2]; if(i0%10==3) return sth[3]; return sth[4]; } //function stndrdth(i0) //9802141626 done js code //sortNumbMan() all ...Man() are MANager //function. Handle input/output. Other //programmer may not need this manager //function. //This manager function call main engine // ouArray=sortNumb(inArray) //Other programmer may want to use sortNumb() // 9807161228 function sortNumbMan(smArg1) //9807151818 { var inArray=readdata(boxc21.value); //9807151819 boxc22.value='' //9807151824 +(''+sortNumb(inArray)).replace(/,/g,'\n'); } //9807151826 function sortNumbMan(smArg1) /** 2009-07-22-11-05 found old record 8902WK01.DLY [[ A tutorial on pointers and arrays in C 2000-02-16-01-57 http://www.netcom.com/~tjensen/ptr/pointers.htm save as pointer_01 to pointer_14 2000-02-16-02-05 http://home.netcom.com/~tjensen/ ]] 02/16/2000 02:04 AM 19,015 ch10x.htm /**/ //bubbleMan() all ...Man() are MANager //function. Handle input/output. Other //programmer may not need this manager //function. //This manager function call main engine // bubble_1(inArray, // inArray.length // ) //Other programmer may want to use bubble_1() // 9807161229 function bubbleMan(bmArg1) //9807151827 { var inArray=readdata(boxc21.value); //9807151819 bubble_1(inArray, inArray.length ) //output 3,2,1 if(bmArg1==1) { //output 1,2,3 inArray=upsidedown2((''+inArray).replace(/,/g,'\n')) //9811240949 } boxc22.value='' //9807151830 +(''+inArray).replace(/,/g,'\n'); } //9807151832 function bubbleMan(bmArg1) /** 9807161850 Assume input sequence is inNumb[]=[ 0.556 -0.145 0.302e3 -0.305e2 -0.088 ] then inNumb[0] store 0.556 inNumb[1] store -0.145 inNumb[2] store 302.0 inNumb[3] store -30.5 inNumb[4] store -0.088 then call newSeq=sortNumb(inNumb) get newSeq=[2,0,4,1,3] it means inNumb[2] store 302.0 greater than inNumb[0] store 0.556 greater than inNumb[4] store -0.088 greater than inNumb[1] store -0.145 greater than inNumb[3] store -30.5 newSeq=[2,0,4,1,3] this new sequence can be used to re-order eigenvalue and to re-order eigenvector 9807161856 stop 9807271355 start above inNumb[0] ... inNumb[4] old index is bb = [0,1,2,3,4] function sortNumb() main job is to change index to [2,0,4,1,3] If sort number directly, use if (aa[j] > aa[i]) sortNumb() sort number IN-directly sort number index bb[i] directly, use if (aa[bb[j]] > aa[bb[i]]) 9807271401 stop /**/ //function bubble(aa, N //9807151528 function sortNumb( //9807151528 aa //aa is input number sequence. ) { // 9807151612 and 9807151616 are two key points var N=aa.length; //9807151625 var bb=new Array(N); for(var m0=0;m0<N;m0++) bb[m0]=m0; //9807250842 //above line, create bb=[0,1,2,3,4] var i, j, k; for (i = 0; i < N-1; i++) { for (j = i+1; j <= N-1; j++) { // if (aa[j] > aa[i]) //from greatest to smallest if (aa[bb[j]] > aa[bb[i]]) //9807151616 { k=bb[i]; //9807151612 bb[i]=bb[j]; //9807151611 bb[j]= k ; //9807151613 } //if (aa[bb[j]] > aa[bb[i]]) } //for (j = i+1; j <= N-1; j++) } //for (i = 0; i < N-1; i++) return bb; // 9807161630 } //9807151617 function sortNumb() /** 9807271416 start loop command for (i = 0; i < N-1; i++) for (j = i+1; j <= N-1; j++) work as following assume input data is aa[0] = 0.556 aa[1] = -0.145 aa[2] = 302.0 aa[3] = -30.5 aa[4] = -0.088 original index is bb=[0,1,2,3,4] Goal is to find new order as below aa[2] = 302.0 aa[0] = 0.556 aa[4] = -0.088 aa[1] = -0.145 aa[3] = -30.5 right hand side of '=' is in great to small order new index is bb=[2,0,4,1,3] First enter outer loop for (i = 0; i < N-1; i++) Index [0,1,2,3,4] has five number, so N=5 i start from 0, 1, 2 to 3 . i not touch 4 ÿi < N-1 ÿ If i=4 then last number aa[4] no one to compete with aa[4] . Need at least reserve one number to compete with aa[i] Therefore, Five number sequence, i not reach 4 N number sequence, i not reach N-1 If it is just begin, i=0 . aa[0] is main role. Next see inner loop for (j = i+1; j <= N-1; j++) index j start from i+1=1 j goto 4 and stop. ÿj <= N-1 ÿ In inner loop, outer loop index i is constant, never change. Take aa[1],aa[2],aa[3],aa[4] One after one, compare with aa[0]. If it is just begin, old order is bb=[0,1,2,3,4] command if (aa[bb[j]] > aa[bb[i]]) is if (aa[bb[1]] > aa[bb[0]]) is if (aa[1] > aa[0]) is if (-0.145 > 0.556) Not true, not run if(true) commands Inner loop index j increase get j=2 At this time, outer loop index i still =0 command if (aa[bb[j]] > aa[bb[i]]) is if (aa[2] > aa[0]) is if (302.0 > 0.556) It is TRUE !! run if(true) commands k=bb[i]; bb[i] value store at k bb[i]=bb[j]; bb[i] receive bb[j] value bb[j]= k; bb[j] receive bb[i] value that is bb[i] and bb[j] exchange value. Before first exchange bb=[0,1,2,3,4] After first exchange bb=[2,1,0,3,4] bb[j] compare with bb[i] continue as above fashion. Until all done, get new index sequence bb=[2,0,4,1,3] command return bb; // 9807161630 send new index back to calling function. 9807271441 stop /**/ /* Program bubble_1.c from PTRTUT10.HTM 6/13/97 Ted Jensen Redwood City, California tjensen@ix.netcom.com July 1998 //9807151221 open C:\lc0\c_online\pointer\ch10x.htm void bubble(int a[], int N) */ function bubble_1(a, N // , bb //9807151249 bb store new sequence, but ) //failed, then have to write sortNumb() { //alert('bubble_1, a='+a+'\n'+'N='+N+', 9809281207'); // int i, j, t; var i, j, t; for (i = N-1; i >= 0; i--) { for (j = 1; j <= i; j++) { // if (a[j-1] > a[j]) //9807151238 change to next if (a[j-1] < a[j]) //from greatest to smallest { t = a[j-1]; a[j-1] = a[j]; a[j] = t; } } } } /*---------------------- end bubble_1.c -----------------------*/ /** //9809291954 if box11 has [[ 0.556 -0.145 0.302e3 -0.305e2 -0.088]] last line no newline byte, next line inStr0=boxc21.value+'\n'; do not help .split() know box11 last line no newline byte, even if I attach '\n', .split() still drop '\n' from last line. then after upside down first line (was list line and no newline byte) and second line string to one line. 98,09,29,20,36 record //9809292038 version two in output string add '\n', success ouStr0+='\n'; //9809292040 9809291951 upsidedown(), onclick='upsidedown()' 9811220924 upsidedown2() onclick='boxc22.value=upsidedown2(boxc21.value)' function upsidedown() /**/ function upsidedown2(udArg1) { //var inStr0=boxc21.value var inStr0=udArg1; //9811220928 var ouStr0=''; var p0,p1,p2; inStr0=inStr0.split('\n'); ouStr0=inStr0[inStr0.length-1]; if(ouStr0.charCodeAt(ouStr0.length-1)>=32) ouStr0+='\n'; //9809292040 for(p0=inStr0.length-2;p0>=0;p0--) { ouStr0+=inStr0[p0] //9809292048 +(inStr0[p0].charCodeAt(inStr0[p0].length-1)<32?'':'\n') //9811241012 solve problem ; } return ouStr0; //9811220929 }//9809292050 // function upsidedown2(udArg1) //--> </script>