tag:blogger.com,1999:blog-86211793913842564772024-02-21T04:33:28.773+00:00GnumbersGaryhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.comBlogger37125tag:blogger.com,1999:blog-8621179391384256477.post-13774313138996229072023-04-13T17:47:00.002+01:002023-09-16T12:28:15.218+01:00sal1520 abundant relations make it ...<p> A new [financial] year and a new book</p><p>First 6 chapter titles listed below:</p><ul style="text-align: left;"><li>Chapter 1: Metaverse - Sharing a power - asymmetric setup t=228 (silver)<br /></li><li>Chapter 2: Metaverse - Object exchange using (small) data bandwidth t=329<br /></li><li>Chapter 3: Metaverse - test key examples are 'fluted'<br /></li><li>Chapter 4: Metaverse - Recap and source of asymmetric strength<br /></li><li>Chapter 5: Metaverse - Bare bones draft spec for inter metaverse object exchange<br /></li><li>Chapter 6: GP example and links<br /></li></ul><p>...</p><p><br /></p><p>Next the downloadable pdf</p><ul style="text-align: left;"><li><a href="https://drive.google.com/file/d/16coaj9LF9oasW2QsmNStUo_G1vS1SLCX/view?usp=sharing" rel="nofollow">sal1520 abundant relations make it...</a><br /> </li></ul><p>( free copy just include a couple of termite images to distinguish from a paid copy ) <br /></p>Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.comMerseyside, UK53.3976041 -2.943664325.087370263821157 -38.0999143 81.707837936178848 32.2125857tag:blogger.com,1999:blog-8621179391384256477.post-70538328384220676792023-01-01T00:10:00.002+00:002023-01-01T00:10:17.935+00:00Agile Mathematics for Strong Hashing<p> A new year and a new book</p><p>First 6 chapter titles listed below:</p><ul style="text-align: left;"><li>Chapter 1: Ingredients</li><li>Chapter 2: Large proth primes and computer testing / calculation</li><li>Chapter 3: Pivoting into other areas of Mathematical exploration</li><li>Chapter 4: 2014 to 2017/2018</li><li>Chapter 5: 2018 and 2019 starting to gel</li><li>Chapter 6: Review and claims</li></ul><p>...</p><p><br /></p><p>Next the downloadable pdf</p><ul style="text-align: left;"><li><a href="https://drive.google.com/file/d/18luywMvThjP_2KfnIa82Z-0h5ZNa5nl0/view?usp=sharing" rel="nofollow" target="_blank">Agile Mathematics for Strong Hashing</a><br /> </li></ul><p>( free copy just include a couple of termite images to distinguish from a paid copy ) <br /></p><p> <br /></p>Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0Merseyside, UK53.3976041 -2.943664325.087370263821157 -38.0999143 81.707837936178848 32.2125857tag:blogger.com,1999:blog-8621179391384256477.post-79632928499937080212019-09-12T22:17:00.001+01:002019-09-12T22:17:27.485+01:00proth research - directories and more directoriesAfter several years of working with Proth numbers, looking for interesting properties, a filesystem will get pretty packed!<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGridRsz4XKfSqTtSUayuTfPMG2zau1ldP-onbGUDffVWnAlLxwyfuPGxrS9-_V74vfL25f_dtvJdCr8iR-epYyl9YgCAHYhuZYJBXhhmmKUxL2LGvxyMNP-SP-JnUDOKSIyK7uTH7IuNO/s1600/prsal1of3dirs.jpeg" imageanchor="1"><img border="0" data-original-height="809" data-original-width="1229" height="263" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGridRsz4XKfSqTtSUayuTfPMG2zau1ldP-onbGUDffVWnAlLxwyfuPGxrS9-_V74vfL25f_dtvJdCr8iR-epYyl9YgCAHYhuZYJBXhhmmKUxL2LGvxyMNP-SP-JnUDOKSIyK7uTH7IuNO/s400/prsal1of3dirs.jpeg" width="400" /></a>
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5qbD6RZ97k6Yr9npmeOujToOKZ11o_N5y8gfzuiTqncPwCyc2NOov_VewBdCwNvxz629EwgE1uDBfr1yRD9VmFyMmK1WJN5iqGvG-4v1HvwiWXnCRq6okPVJkg1LBIz1akRmt9AwcEU-W/s1600/prsal2of3dirs.jpeg" imageanchor="1"><img border="0" data-original-height="809" data-original-width="1222" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5qbD6RZ97k6Yr9npmeOujToOKZ11o_N5y8gfzuiTqncPwCyc2NOov_VewBdCwNvxz629EwgE1uDBfr1yRD9VmFyMmK1WJN5iqGvG-4v1HvwiWXnCRq6okPVJkg1LBIz1akRmt9AwcEU-W/s400/prsal2of3dirs.jpeg" width="400" /></a><br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpyPoN-D3aejbUGfGwJThjpKwzQNrdTE_8aLExf1X_hIgxux-5nPblD8sfGPQ3cC0Jy6k-qlCUwPvDCv9B6d6KKE0NRahxHqU8CiHuEL1y0EqCyyqrZIPLWAjdtsss7nB8hZl3f9bcaOzX/s1600/prsal3of3dirs.jpeg" imageanchor="1"><img border="0" data-original-height="808" data-original-width="1264" height="256" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpyPoN-D3aejbUGfGwJThjpKwzQNrdTE_8aLExf1X_hIgxux-5nPblD8sfGPQ3cC0Jy6k-qlCUwPvDCv9B6d6KKE0NRahxHqU8CiHuEL1y0EqCyyqrZIPLWAjdtsss7nB8hZl3f9bcaOzX/s400/prsal3of3dirs.jpeg" width="400" /></a>
<br />
<br />
How do I organise directories in a mass of say 500 or 1000 directories? Starting off with fixed so prothleadNNNNNN (Example: prothlead8388607)<br />
<br />
If/when I find something interesting, and think its worth generalising, then I just replace the NNNNNN number with a short sequence of characters.<br />
They have no meaning generally, just a way of making things stand out in a mass of directories.<br />
<br />
What you can see from the final image 'prSAL' is how I labelled the prothlead8388607 directories after I generalised away from just the t=23 case. It helped to quickly think up something short - just a way of less typing at the time.<br />
<br />
I could still be writing prothlead8388607 today but it just felt like too much and so i found a shorter thing that just occurred to me at the time.
( pretty arbitrary )<br />
<br />
I could keep posting screenshots until I had 10 images on screen here to show the problem in hunting around in Proth numbers over a period of 7 years and keeping things organised in directories!<br />
<br />
<br />Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-78213057523587935042019-09-12T10:40:00.001+01:002019-09-12T21:39:37.379+01:00When 2*16 congruent to 5*29 do we still have Unique Factors?Commutative algebra / abstract algebra was a joy to study, and coupled with Number theory is a superb grounding for second and third year undergraduate study.<br />
<br />
Current lecture notes and set texts seem to suggest that whenever p is prime, that Z/pZ is an integral domain, a unique factors setup, ... and a Field.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2ZgIzqNN4NMg5wvybG_JbbVdtO3QR1IVxZ-lco3Zcz_lQu-2xRXuTXsAjGqxPuQTrhnrFeHhe0TnLkY0csTKUlQhEG9vfvr01Gu6Ii9FeSJ6SbcAlG4r2pwLge_6sAKouZozLfYkjW3J3/s1600/pr3problemUFD.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="510" data-original-width="772" height="422" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2ZgIzqNN4NMg5wvybG_JbbVdtO3QR1IVxZ-lco3Zcz_lQu-2xRXuTXsAjGqxPuQTrhnrFeHhe0TnLkY0csTKUlQhEG9vfvr01Gu6Ii9FeSJ6SbcAlG4r2pwLge_6sAKouZozLfYkjW3J3/s640/pr3problemUFD.jpeg" width="640" /></a></div>
<br />
Quoting from some MIT lecture notes:<br />
"We call R a Unique Factorization Domain(UFD) if every nonzero element is a product of irreducible elements in a unique way up to order and units"<br />
<br />
Take a look at the image above and see what you think?<br />
<br />
The key thing that is easy to overlook is the part of the definition that says 'irreducible elements' <br />
<br />
Here we would need to check each of the 4 elements 2,16,5,29 are irreducible mod 113.<br />
We would not say that 16 is 'irreducible'<br />
<br />
Links and References:<br />
<ul>
<li><a href="https://www.quora.com/Why-do-integers-mod-a-prime-number-create-a-finite-field" rel="nofollow">https://www.quora.com/Why-do-integers-mod-a-prime-number-create-a-finite-field</a></li>
<li><a href="http://web.mit.edu/18.705/www/12Nts-2up.pdf" rel="nofollow">MIT lecture notes - commutative algebra</a> </li>
<li><a href="http://www.stackprinter.com/export?question=16416&service=mathoverflow" rel="nofollow">List of supplementary commutative algebra texts - mathoverflow list</a></li>
</ul>
Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-90809397978405172012019-09-10T21:59:00.000+01:002019-09-19T12:47:55.550+01:00subset of proth with ord2 property that is interesting - submission progress for these new primesHave submitted a list of primes in a new sequence to oeis and waiting on publication approval.<br />
<br />
Sometime these things take a while, so in order to ensure provenance and dates, here are a few snapshots of the in progress submission.<br />
<br />
The publishing process has been a little more involved than I thought. Keeping the PROG element below for future reference.<br />
<br />
One aspect that did not make it into the published version was the Conjecture that I added in an effort to unstick the process. I repeat it here so that it is not lost in old history.<br />
<br />
<blockquote class="tr_bq">
<b>Conjecture</b>: There are NO Proth numbers of form pr=1+(-1+2^n)*2^(n+1) ), for which, working modulo pr the congruence -1== 2^(2*(1+2*n)) modulo pr is FALSE</blockquote>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPGsKKWJ63YXNhAlPaXGVOwbTGNlle_wGQcc1-A9GPQ3F_5s0E3KjCbOwZa1lhgNFWizDIEXfiFyl3wyzG_MVUs6eub2138E19tshOc4AsaRI8I03F_aSDK0i8WvtwRU6uxqUp2u-DPpcX/s1600/n_form_proposed201909.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="831" data-original-width="983" height="540" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPGsKKWJ63YXNhAlPaXGVOwbTGNlle_wGQcc1-A9GPQ3F_5s0E3KjCbOwZa1lhgNFWizDIEXfiFyl3wyzG_MVUs6eub2138E19tshOc4AsaRI8I03F_aSDK0i8WvtwRU6uxqUp2u-DPpcX/s640/n_form_proposed201909.jpeg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihVSt5Nn5QMSv7c7C5JCClf3HN5LCRebIgHbjjnHUBLtqsOQU4CYTcb0n2t0xn4Gxemn3Bxa4LP7fdMZODG9_V28Sn-au5hbssfY_4F2_KJBzOslSTZkhw7ebujv05-AxRCEPfthr4Hnbp/s1600/original_t_form_proposed201909.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="785" data-original-width="920" height="341" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihVSt5Nn5QMSv7c7C5JCClf3HN5LCRebIgHbjjnHUBLtqsOQU4CYTcb0n2t0xn4Gxemn3Bxa4LP7fdMZODG9_V28Sn-au5hbssfY_4F2_KJBzOslSTZkhw7ebujv05-AxRCEPfthr4Hnbp/s400/original_t_form_proposed201909.jpeg" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Links and references:</div>
<ul>
<li>Published sequence <a href="http://oeis.org/A325914" rel="nofollow">A325914</a> [ oeis.org ] Proth primes</li>
<li><a href="https://bitbucket.org/wrightsolutions/sal683onetime" rel="nofollow" target="_blank">sal683onetime (onetime encryption scheme)</a> </li>
<li><a href="https://oeis.org/search?q=author%3AGary+Wright&sort=&language=&go=Search" rel="nofollow">oeis.org - author search</a> </li>
</ul>
<br />Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-26249965191981791382019-06-23T13:47:00.000+01:002019-06-23T13:47:10.771+01:00pari operation time - Miller RabinSetting 1 in the call to ispseudoprime() in Pari/GP will get you a strong pseudoprime test (Miller-Rabin)<br />
<br />
Pseudoprime tests are more practical first attempts when dealing with huge inputs ( In this example the number has 632202 decimal digits )<br />
<br />
How long did the operation take? <b>##</b> shows 13 hours 58 minutes<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtt28EQJYtleuWc06HJReSnLwrTI7v1MpBwLCcptSrbAH2o1gVg2xsQRPR-6YR_YAloxh8oX_Tc6TOoVgE1d0-NBkVGehY9EqtbLCeyVUrRsT8C3ZmfdMgij94xe_OPrr1FAG76Ou5fe08/s1600/t1050083compositeMRresultPari2.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="535" data-original-width="542" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtt28EQJYtleuWc06HJReSnLwrTI7v1MpBwLCcptSrbAH2o1gVg2xsQRPR-6YR_YAloxh8oX_Tc6TOoVgE1d0-NBkVGehY9EqtbLCeyVUrRsT8C3ZmfdMgij94xe_OPrr1FAG76Ou5fe08/s1600/t1050083compositeMRresultPari2.jpeg" /></a></div>
<br />
<br />
<br />
Link and further reading:<br />
<ul>
<li>Miller-Rabin [ <a href="https://www.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test" rel="nofollow" target="_blank">wikipedia</a> ] </li>
<li><a href="https://github.com/wizykowski/miller-rabin" rel="nofollow" target="_blank">Alternative C implementation</a> of Miller-Rabin by W Izykowski</li>
</ul>
<br />
<br />Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-10127140344654367872019-06-13T12:10:00.000+01:002019-06-13T12:10:33.892+01:00ABC and ABCDN formats for input to LLR and PFGW - numeric constructionWith the creation of organised projects for prime number searching, and the retirement of some of the leading C program creators, the knowledge about ABC and ABCDN format is harder to find.<br />
<br />
Here I gather a few links (see references) and show a source code sample that will help point you in the right direction.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKyPu_nP7JPViB_j7k3FxCetva6USFiTcbQDF_4eJpRkZjO-IEV09U50aSdGf8ycGXxBE2Qcu-_rohQkZcKFnReBlvf3xdHeEMN7DCmvW65SoG3czfQhaMNalsQ3muqFYdidG3g1pSamQA/s1600/formatABCandABCDNinLLRsource.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="393" data-original-width="694" height="361" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKyPu_nP7JPViB_j7k3FxCetva6USFiTcbQDF_4eJpRkZjO-IEV09U50aSdGf8ycGXxBE2Qcu-_rohQkZcKFnReBlvf3xdHeEMN7DCmvW65SoG3czfQhaMNalsQ3muqFYdidG3g1pSamQA/s640/formatABCandABCDNinLLRsource.jpeg" width="640" /></a></div>
<br />
<br />
LLR is great for standard formats (commonly mined prime areas) and is able to cope with many different formats, however where you differ from some of the more common +1 and -1 forms, the following warning is given in the program readme:<br />
<blockquote class="tr_bq">
- K*b^n+c numbers with |c| < > 1 or k > b^n can only be PRP tested.<br />
<br />
If the number is found PRP, the % of factorization is then shown,<br />
but note that it is relevant only if c == +1 or -1...</blockquote>
<br />
<br />
<b>References and links:</b><br />
<ul>
<li>LLR implements "Lucas-Lehmer-Riesel" and Proth algorithms - <a href="http://jpenne.free.fr/index2.html" rel="nofollow" target="_blank">source</a></li>
<li>OpenPFGW - <a href="https://sourceforge.net/projects/openpfgw/" rel="nofollow" target="_blank">source</a></li>
<li>OpenPFGW page about <b>ABC</b> and ABC2 and ABCD - <a href="https://sourceforge.net/p/openpfgw/code/HEAD/tree/distribution/abcfileformats.txt" rel="nofollow" target="_blank">text</a></li>
<li>Caldwell pages at University of Tennesse at Martin - <a href="https://primes.utm.edu/programs/" rel="nofollow" target="_blank">program links</a></li>
</ul>
<br />Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-59522750491389207482017-09-02T20:17:00.000+01:002017-09-03T13:19:06.513+01:00High performance [mathematical] computingWhen talking about supercomputers, there is a temptation to define things in terms of either of the following:<br />
<ol>
<li>massive simulations </li>
<li>they mean maths</li>
</ol>
Here is a phrase used in a recent discussion about high performance computing (hpc) that points to the first definition for my mind ...<br />
<blockquote class="tr_bq">
The term number-crunching refers to large-scale numerical simulations </blockquote>
Now simulations of spacecraft flight or the effects of adding a dam to a major river really are typical uses of hpc <br />
<br />
However, thinking about (2 ... they mean maths), you have many uses of hpc where the Mathematics itself is the outcome.<br />
<br />
For people who are learners of hpc, I can see why the 'massive simulations' message is preferred as a way of presenting the <b>utility</b> of hpc<br />
<br />
However as a Mathematician I naturally think also of many scenarios where the Mathematics is the outcome.<br />
<br />
Not all of those outcomes will be moved onto a powerful workstation in the next decade.<br />
<br />
There is also another major use of hpc which is not really [in my opinion] a good fit for the word simulation. Natural language processing at very high speed is one of the prerequisites of AI.<br />
<br />
In such a context you are not simulating the process of adding meaning to raw words, you are actually <b>doing it</b> when you task a hpc with such processing.Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-91115579575840887022017-02-14T21:44:00.001+00:002017-02-14T21:44:36.076+00:00shifting from m1q 898739...000591Here is a fun loop for you to code up in Pari/GP and examine the output<br />
<br />
<code>m1q=89873960570712084732829528260849073549900665278240478747684257744366000579315782083148000591
</code>
<br />
<br />
<code>for(k=9000,10000,n=m1q+2+3*k;n6=n%6;prim=0;if(0==n6,prim=isprime(n/6));print("k=",k," gives ",prim,"=isprime(n/6)");if(prim>0,break))
</code>
<br />
<br />
Sample output for loop starting k=9000 <br />
<br />
k=9000 gives 0=isprime(n/6)<br />
k=9001 gives 0=isprime(n/6)<br />
...<br />
k=9250 gives 0=isprime(n/6)<br />
k=9251 gives 1=isprime(n/6)<br />
<br />
Here is a slightly improved loop:<br />
<br />
<code>for(k=9000,10000,n=m1q+2+3*k;n6=n%6;prim=0;if(0==n6,print("k=",k," 0==n/6");prim=isprime(n/6));print(" gives ",prim,"=isprime(n/6)");if(prim>0,break))
</code>
<br />
<br />
k=9249<br />
0==n/6<br />
gives 0=isprime(n/6)<br />
gives 0=isprime(n/6)<br />
k=9251 0==n/6<br />
gives 1=isprime(n/6)<br />
<br />
<br />
m1q is prime and has the following construction:<br />
<br />
<code>t=193;m1=((-1+(3^(t))*37));m1q=m1/50
</code>
Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-89217460214673016802016-02-08T03:20:00.001+00:002016-02-10T00:25:50.498+00:00primes and quadratic involving deduction of 2Take a prime p and double it then deduct 5 to obtain 2p5<br />
<br />
candidate = -2+p*2p5<br />
<br />
Is candidate prime?<br />
<br />
Example p=53 so 2p5 =101<br />
<br />
5351=-2+53*101<br />
5351 is <b>prime</b><br />
<br />
Next try p=47 so 2p5 = 89<br />
<br />
4181=-2+47*89<br />
4181=37*113 <br />
<br />
<br />
Next try p=59 so 2p5 = 113<br />
<br />
6665=-2+59*113<br />
6665=5*31*43<br />
<br />
Next try p=61 so 2p5 = 117<br />
<br />
7135=-2+61*117<br />
7135=5*1427<br />
<br />
<br />
Next try 67 so 2p5 = 129<br />
<br />
8641 is <b>prime</b><br />
<br />
Now algebraically we might say -2+p*(2p-5) which is rewritten 2p^2-5p-2<br />
<br />
Next try 71 so 2p5 = 137<br />
<br />
9725=-2+71*137<br />
9725=5*5*389<br />
<br />
<br />
Next try 73 so 2p5 = 141<br />
<br />
10291=-2+73*141 <br />
10291=41*251<br />
<br />
Next try 79 so 2p5 = 153<br />
<br />
12085=-2+79*153<br />
12085=5*2417<br />
<br />
Next try 83 so 2p5 = 161<br />
<br />
13361=-2+83*161<br />
13361=31*431<br />
<br />
Next try 89 so 2p5 = 173<br />
<br />
15395=-2+89*173 <br />
15395=5*3079<br />
<br />
<br />
Next try 97 so 2p5 = 189<br />
<br />
18331=-2+97*189<br />
18331=23*797<br />
<br />
Next try 101 so 2p5 = 197<br />
<br />
=-2+101*197<br />
=5*23*173<br />
<br />
<br />
Next try 103 so 2p5 = 201<br />
<br />
20701=-2+103*201<br />
20701=127*163 is composite<br />
<br />
<br />
Next try 107 so 2p5 = 209<br />
<br />
22361=-2+107*209<br />
22361=59*379 is composite<br />
<br />
<br />
Next try 109 so 2p5 = 213<br />
<br />
23215=-2+109*213<br />
23215=5*4643 is 5 divisible<br />
<br />
<br />
<br />
Next try 113 so 2p5 = 221<br />
<br />
24971=-2+113*221<br />
24971 is <b>prime</b><br />
<br />
<br />
Answer will be divisible by 5 when -2+2p^2 is divisible by 5<br />
( or written another way answer cannot be divisible by 5 when -2+2p^2 is not divisible by 5 ) <br />
<br />
<br />
Now we redo the above example but with slightly different assignment for p<br />
<br />
Set the prime 113 then deduct a 100 and use that figure as p<br />
<br />
13 is prime<br />
p=13<br />
<br />
113=p+10^2<br />
<br />
221 = p*(p+4)<br />
<br />
-2+(p+(2*5)^2)*p*(p+4)<br />
<br />
<br />
<b>prime</b> 24971==-2+113*221 ( 221 is 13*17 )<br />
<br />
<br />
p=17<br />
<br />
-2+(p+(2*5)^2)*p*(p+4)<br />
<br />
41767=-2+117*17*21<br />
41767=11*3797<br />
<br />
<br />
p=19<br />
<br />
-2+(p+(2*5)^2)*p*(p+4)<br />
51201=-2+(7*17)*(19*23) <br />
51201=149*349<br />
<br />
<br />
p=1053 so p+100 is 1053<br />
p2=1053<br />
<br />
<b>prime</b> 1283313211==-2+1153*(1053*1057)<br />
<br />
( 1283313213==(3^4)*7*13*151*1153 ) <br />
<br />
<br />
Now let us vary things slightly by defining p2=p+100 and having our answer derived as -2+(p2^2)*(p2+4)<br />
<br />
p=953 <u>which is prime</u> and then p+100 is 1053<br />
p2=1053<br />
<br />
<b>prime</b> 1172011111==-2+1053*(1053*1057)<br />
<br />
( 1172011113==(3^8)*7*(13^2)*151 )<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUotxlv8ZywsdAKC1fstvXzu2y8rKs99DOK2zmHbunPPQlWknplZrexoejBTQCn2HNmo-Oa3HqusSE4KSQ4ESsZc1IT3RPaaYMB6EvOSCW-e_56wBr45IfDFGaGBp8doiR9TtsuoCndV0-/s1600/p2based.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="432" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUotxlv8ZywsdAKC1fstvXzu2y8rKs99DOK2zmHbunPPQlWknplZrexoejBTQCn2HNmo-Oa3HqusSE4KSQ4ESsZc1IT3RPaaYMB6EvOSCW-e_56wBr45IfDFGaGBp8doiR9TtsuoCndV0-/s640/p2based.jpeg" width="640" /></a></div>
<br />
<br />
<br />
<br />Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-10503315591216772652013-09-10T15:06:00.001+01:002013-09-10T15:06:50.895+01:00sagemath terminal colours - green > blueSagemath includes an embedded version of ipython and any changes you make to terminal colours need to happen in ipython_config.py in the correct place.<br />
<br />
After doing a sage install there is a directory on my computer at location:<br />
~/.sage/ipython-0.12/<br />
<br />
The goal of this short set of hints is to assist you in creating a suitable profile_sage/ipython_config.py file.<br />
<br />
That file should look like this:<br />
<br />
<pre># Configuration file for ipython.
c = get_config()
# Set the color scheme (NoColor, Linux, or LightBG).
c.TerminalInteractiveShell.colors = 'Linux'
</pre>
<br />
What that will achieve is to make your prompt green instead of blue.<br />
The default (blue) seems a little bright on the eyes, so by setting
colors = 'Linux' you get the less garish <span style="color: #38761d;">green</span> prompt instead.<br />
<br />
You can just run ahead and use geany or another editor to create ipython_config.py with content detailed above.<br />
<br />
If you prefer to look at what iPython itself generates then you might wish to know of these two commands:<br />
<ul>
<li>ipython profile list</li>
<li>ipython profile create justcreatedbyme</li>
</ul>
However be aware that you want to be running the embedded ipython version when doing 'profile create' in order to be sure a a fully compatible profile is created.<br />
( Manual copy / rename things to get file to proper location of<br />
profile_sage/ipython_config.py )<br />
<br />
An example of the output from profile list is shown below:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1DJ0Rcil9ynrnxKWAUsu8h4u3JU31OXj9d40n3BqkBvgon7yi0e3J3iZMoYbmRt3LlchjQIA1U9lKX60W_dIrdNH_Jf6qBRDnpa40m0r0eIHeOudDQ1ZPBYgckocZs6n7i4cch-NElfvl/s1600/ipythonTerminalInteractiveShellToLinuxCol.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="List of profiles available to iPython" border="0" height="524" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1DJ0Rcil9ynrnxKWAUsu8h4u3JU31OXj9d40n3BqkBvgon7yi0e3J3iZMoYbmRt3LlchjQIA1U9lKX60W_dIrdNH_Jf6qBRDnpa40m0r0eIHeOudDQ1ZPBYgckocZs6n7i4cch-NElfvl/s640/ipythonTerminalInteractiveShellToLinuxCol.jpeg" title="ipython profile list" width="640" /></a></div>
<br />Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-21884546118953522902013-06-27T12:54:00.003+01:002013-06-27T12:54:47.396+01:00Power of negative number - pari gpDo use parentheses () to wrap your negative where necessary.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs9kVieZtD-qHyhdhM81364RirQoZslevgfAlbv9j8jIZzsx4jzhNTX9_KuFyc-7i9CXRMbLpDOQf670ax0AquB2ha32loUp6r3AUU_xMAyU_L7_nMQHFU0FDodebQTevRZZo8RCWnLt75/s206/pariPowersOfNegatives__2013Q2pariGP.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs9kVieZtD-qHyhdhM81364RirQoZslevgfAlbv9j8jIZzsx4jzhNTX9_KuFyc-7i9CXRMbLpDOQf670ax0AquB2ha32loUp6r3AUU_xMAyU_L7_nMQHFU0FDodebQTevRZZo8RCWnLt75/s206/pariPowersOfNegatives__2013Q2pariGP.jpeg" /></a></div>
<br />
<br />
<br />
<br />
<br />
Because exponentiation has priority over +/- you should wrap your -1 in parentheses (), or, if just squaring, use the sqr() function.<br />
<br />
The priority of operators in Pari/GP is detailed in Section 2.4 of the <a href="http://pari.math.u-bordeaux.fr/doc.html" target="_blank">User Guide</a> and titled "2.4 GP Operators"<br />
Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-57033768121994123722013-01-20T17:53:00.000+00:002014-04-04T21:08:59.389+01:00number of digits function - sage - sagemathIf you work with Sage a lot, then these two points will help you remember how to get a digit count:<br />
<ul>
<li>Sage uses Objects to represent mathematical constructs</li>
<li>Sage is written in Python</li>
</ul>
<pre><span style="font-size: large;"> two_to_ten=2^10
a_to_power=11^two_to_ten
len(str(a_to_power</span><span style="font-size: large;"><span style="font-size: large;">)</span>)</span>
</pre>
<br />
Answer: 1067<br />
<br />
There are 1067 digits in the number formed when 11 is raised to 1024<br />
<br />
<h3>
Pari/GP and number of digits:</h3>
<br />
In Pari/GP the length() function can be used in a similar way to len() in Sage. In Pari try length(Str(11^1024))<br />
<br />
<br />
You can still <a href="http://www.sagemath.org/doc/reference/sage/interfaces/gp.html" target="_blank">access Pari/GP directly through sage</a>.<br />
<br />
Try this in Sagemath:<br />
<br />
<br />
<span style="font-size: large;"><code>gp("length(Str(11^1024))")</code></span><br />
<br />
<h3>
The very large - two examples using Pari:</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG_AcdoN6SJBKg694qJ2TahtHGWEYP3otyv3zP3QJcvxzz6Ktubn0KdPZc0qPqzJvysFj4yrge9NHnKBXsGXE_eBMZkef2MJLskNXWlf4LKpxzVq-_-E9vzCEkv0DxqsvHx9A6ZNMpfAPx/s1600/length_str_for_num_digits__2014large_examples.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG_AcdoN6SJBKg694qJ2TahtHGWEYP3otyv3zP3QJcvxzz6Ktubn0KdPZc0qPqzJvysFj4yrge9NHnKBXsGXE_eBMZkef2MJLskNXWlf4LKpxzVq-_-E9vzCEkv0DxqsvHx9A6ZNMpfAPx/s1600/length_str_for_num_digits__2014large_examples.jpeg" height="374" width="640" /></a></div>
<br />
<div style="text-align: center;">
( click on the image above for optimal font sizing )</div>
<h3>
Notes and further reading:</h3>
You can check the 11^1024 digit count yourself by following <a href="http://www.wolframalpha.com/input/?i=11%5E1024" rel="nofollow" target="_blank">this</a> wolfram alpha link:<br />
<a href="http://www.wolframalpha.com/input/?i=11%5E1024" rel="nofollow" target="_blank">http://www.wolframalpha.com/input/?i=11%5E1024</a><br />
<br />
Python note: Although sage allow you to use ^ to indicate raising to power, when writing in Python directly you should use the correct ** operator.<br />
<ul>
<li><a href="http://docs.python.org/3/reference/expressions.html#the-power-operator" target="_blank">http://docs.python.org/3/reference/expressions.html#the-power-operator</a></li>
</ul>
Pari/GP is designed particular for number theory, and does not have a
real need to store mathematical constructs as api friendly Objects [by default] in the same
way as Sage does. Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-40497746917964903892012-05-01T13:21:00.000+01:002012-05-01T13:21:12.808+01:00ipython - Better Feedback for BeginnersHaving worked with Python through Sage Mathematics, and directly through Emacs, I never really took the time to understand what IPython offers.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMqtHFnY1Vr6TmIN_swRHTh9Xk2SV2baeyej8MpJvds8YAb_X3gnn782eYvpOk94mlXukqk034p7V_ruiphE9E1U99DrQhz8TCVQ3Y-oGLu08jmwMLS89P2gxZI-zARMlfF-rpYTabrJY_/s1600/ipythonEnhancedErrorReporting__2012Q2python.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMqtHFnY1Vr6TmIN_swRHTh9Xk2SV2baeyej8MpJvds8YAb_X3gnn782eYvpOk94mlXukqk034p7V_ruiphE9E1U99DrQhz8TCVQ3Y-oGLu08jmwMLS89P2gxZI-zARMlfF-rpYTabrJY_/s1600/ipythonEnhancedErrorReporting__2012Q2python.jpeg" /></a></div>
<br />
For beginners or Intermediates who want to try something to see if it adds to their productivity, IPython is worth a look.<br />
<br />
<br />
<b>who and whos:</b><br />
<br />
<span style="font-size: large;"><code>%who</code></span> lists names of all objects, but <span style="font-size: large;"><code>%whos</code></span> shows the list with type and contents summary.<br />
<br />
Depending on your system IPython setup, you may be able to omit the <span style="font-size: large;"><code>%</code></span> at the front and just type <span style="font-size: large;"><code>who</code></span> and similar <br />
<br />
<br />
<br />
<b>'run' and variable inspection:</b><br />
<br />
The <span style="font-size: large;"><code>run</code></span> command executes your python [script] and brings the variable into the interactive namespace.<br />
<br />
There are many more features of IPython like tab completion, history, and logging.<br />
<br />
Do take a look and see if it can add anything to your productivity in Python.<br />
<br />
There is an interactive test site <a href="http://www.pythonanywhere.com/try-ipython/">here</a> if you want to get started now:<br />
<ul>
<li><a href="http://www.pythonanywhere.com/try-ipython/" target="_blank">http://www.pythonanywhere.com/try-ipython/</a></li>
</ul>Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-14152038278443729432011-11-20T13:35:00.001+00:002013-04-07T12:01:24.797+01:00Ex student? How much for £300 per week take home?How much Salary does a graduate have to earn to take home £300 a week?<br />
<br />
Answer: Around <b>£27,000</b> per annum<br />
<br />
<br />
<b>Rough estimate - including Student Loans Company (</b><b>slc)</b><b>:</b><br />
<br />
Assuming a nice round 60% net (tax + NI is approx 40%), we see...<br />
<br />
£300 x 52 gives £15,600<br />
<br />
Divide by .6 to gross up that figure gives you the higher gross of £26,000<br />
<br />
£15,600 / 0.6 = £26,000<br />
<br />
£90 * 12 = £1,080 (annual slc repayment on £26,000)<br />
<br />
Estimate: £<b>27,080</b><br />
<br />
<br />
<b>But 40% for tax & NI is wrong? But £90 per month slc is wrong?</b><br />
<br />
These figures are a bit rough and ready. Feel free to substitute your own percentages.<br />
<br />
A spreadsheet to help with the monthly repayment to slc can be found <a href="http://static.wrightsolutions.co.uk/guide/publishedatbloggnumbers/gnumbers11/slcMonthly.ods">here</a><br />
<br />
Note: Spreadsheet is in Open Document format (.ods).<br />
<div style="text-align: left;">
Download LibreOffice to edit or view locally<a href="http://www.libreoffice.org/download"><br /></a></div>
<br />
You can view it directly in Googledocs <a href="https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0ApAp7BMj218VdDNEYTdxckEwYXhiQ3VsYU9Ddjd3aFE&output=html">here</a> <br />
<br />
<br />
Below is a preview image:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-EIXkve5nJxp54JUx7e3e1cdi7Gg1A7TX-A3ABqMN-5pMzXI4bDzTCww-2ybq5Z2H2yDyBC020v9DN8p4ez3oeUbxkotmE6vUWe0BGRLwz4a4eIr-4_eJcE65KxvhYAkri9A-StE2ixIa/s1600/slcMonthly__2011Q4cropped.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-EIXkve5nJxp54JUx7e3e1cdi7Gg1A7TX-A3ABqMN-5pMzXI4bDzTCww-2ybq5Z2H2yDyBC020v9DN8p4ez3oeUbxkotmE6vUWe0BGRLwz4a4eIr-4_eJcE65KxvhYAkri9A-StE2ixIa/s1600/slcMonthly__2011Q4cropped.jpeg" /></a></div>
<br />
<br />
The Tax and National Insurance rate estimates are local to the United Kingdom, please adjust as appropriate for your local situation.<br />
<br />
<h4>
UK Zero Percent Tax threshold in 2014:</h4>
From April 2014 the personal tax threshold (level below which no income tax is payable) is estimated at £10,000<br />
<br />
What this means for somebody earning £27,000 is that 17,000 of their salary is taxed at entry level tax rate of 20%.<br />
Making Annual income tax liability of £3,400 (Monthly £283.33) <br />
<br />
The earlier statement "tax + NI is approx 40%" overstates things a little. Being an employee on that sort of salary means paying 12% National Insurance (NI).<br />
<br />
Update the spreadsheet to reflect the current picture and get a more accurate estimate.<br />
<br />
The £90 monthly payment to your Student Loan is still payable, and is not affected by changes in Tax or NI rates.Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-90238591572232716192011-11-05T23:08:00.003+00:002011-11-05T23:12:21.198+00:00Science - who should have a voice? is silence Scientific?I am not anti-vax, I am not pro-vax, and I am no more comfortable with the ex actor becomes science voice, than I am with ex actor becomes president.<br />
<br />
One thing that I would say, is that whilst I am no fan of Mr Celebritee, or Ms Ex Baywatch, it would also not be entirely wise, to smack down completely, all voices from outside the Scientific establishment.<br />
<br />
It maybe in 15 or 20 years that Science (the community) has more of your faith, or less of your faith, but whatever, it might not be the same level as today.<br />
<br />
If I could turn down the volume level on the non-science stuff/people then that would be great, but be careful of pursuing a policy of Science (establishment) or strict silence.<br />
<br />
Here is an illustration:<br />
<br />
<pre>Science - Non-science celeb
. - A
a - A
A - A
A - a
A - .
</pre><br />
The final option above is the 'Scientific establishment only' viewpoint - where you might advocate nothing else having a voice.<br />
This option is not what I would choose.<br />
Neither would I choose the first or second lines above.<br />
<br />
I have been on the receiving end of some difficult reading in the past.<br />
Reading journalists using pseudo-science to build a following around a view, that serves corporate lobbyists, but also their own profile, is painful.<br />
<br />
I do not have a total solution.<br />
<br />
The Internet has created a great way of building a community around celebrity messages.<br />
Sometimes those celebrities are not in it for the good of that community, and may even be part-funded by a company that stands to make a good profit, from debunking the current Scientific view in a particular area [ allegedly ]<br />
<br />
One solution is to give all citizens at least some introductory experience in critique, and researching of funding/sponsorship.<br />
In the UK we have school leavers well versed in Facebook likes and shares, but who have no idea how to critique or spot a 'sponsored' report.<br />
<br />
The very fact that political lobbying is so successful in the West, is testament to how lacking, in even basic critique, some countries citizens really are.<br />
<br />
<br />
<b>Celebrity bloggers do science - Is this the return of Quackery?</b><br />
<br />
Possibly.<br />
<br />
However listening (entirely) to the Science establishment reaction to this, might see too strong a response.<br />
<br />
I watched a TV programme in 2011 where the President of the Royal Society, <a href="http://royalsociety.org/people/paul-nurse/">Sir Paul Nurse</a> talked about the state of Science, and the rise of the celebrity blogger.<br />
<br />
I agreed with much of what was said in that programme, however [ going back to the critique :) ], there is a billion pound Science industry in the UK, and most of what was said is, what you might expect of somebody seen as a figurehead for the Science establishment.<br />
<br />
One thing that I seem to recall was the message that Science is on trial because of recent events / debates.<br />
<br />
In order to have a trial, you need a jury, even though that jury may include types who you personally cannot stand :)<br />
<br />
The Science establishment cannot be it's own jury*. Perhaps our job might be to ensure that, where practical, we enhance (and share) our personal critique skills, and be aware of how to spot the quackery.<br />
<br />
jury* here does not mean peer review. Peer review is very important and I respect that, however if an 'alternative view' is growing stronger because of celebrity bloggers, then perhaps it is unwise to ignore how the 'lay person' feels about Science. Just how are you going to address this Scientists?<br />
<br />
To avoid any confusion: I am an advocate of peer review, and appreciate how important this is - recent example - the reexamination of the 'faster than speed of light' speculation of European Physicists in 2011 - stimulated by CERN / observations between Switzerland and Italy.<br />
<br />
I am not a Physicist, and have no clue about relativity.<br />
However as a lay person (in the area of Physics), it is helping my faith in that area of Science, when I see such a 'peer review' process in action.<br />
<br />
However the Scientific establishment is not infallible (see link below)<br />
Science is not the only voice I want to listen to.<br />
My (personal) choice is to listen closely when Scientists speak, but also, not to assign zero weight to other voices.<br />
<br />
Whilst I appreciate the importance of established Scientific Journals, I also appreciate the need for <a href="http://www.wikipedia.org/wiki/ArXiv">arxiv</a><br />
<br />
<br />
<b>Notes and Further Reading:</b><br />
<br />
Extract from Heaviside (from link below):<br />
<blockquote class="tr_bq">Heaviside was not interested in rigour...</blockquote>Whist rigour and proof are very important, there are very occasionally folks, who despite resisting rigour and process, manage to discover and apply something magnificent.<br />
( Just to be crystal clear here I am thinking about Heaviside, and not any celebrity bloggers that I have read to date )<br />
<br />
Heaviside did eventually get the recognition that he deserved, however the people who he did not 'get on with' entirely, managed to delay that recognition by several years.<br />
<ul><li><a href="http://www.gap-system.org/~history/Printonly/Heaviside.html">Biography of Heaviside</a> [ www.gap-system.org ]</li>
</ul><div><br />
The Scientific Establishment is a people system, and just like any people system (or computer system), is likely chock full of imperfections.</div><div><br />
</div><div>However my personal view, it that the Scientific Establishment (currently) does a pretty good job, so I will keep listening.</div><div><br />
</div><div>There have been at least two major Science debates in the last decade, where public opinion has really entered into the debate. In neither case, have I personally seen anything, that had me thinking, on those particular issues, that Science was wrong.</div><div>However I do not rule out in the future, the possibility, that I might find myself disagreeing with Science on a particular issue either.</div><div><br />
</div><div>For me it is an issue by issue thing. On individual topics, I try to critique where I can.</div><div><br />
</div><div>Want to help make Science more open? Read the manifesto and <a href="http://sciencecodemanifesto.org/endorse">consider endorsing</a>.</div><div><br />
</div><div>Note: I have no personal affiliation to Nick Barnes or <a href="http://sciencecodemanifesto.org/">that manifesto</a>, read and critique what is said for yourself.</div>Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-24403486451029432122011-10-08T12:00:00.000+01:002011-10-08T12:00:48.332+01:00Pure Mathematics and the horror of numbers<blockquote>He was a pure mathematician who used to work entirely with abstract symbols, but had now sunk so low that his latest report contained actual numbers, indeed numbers with decimal points; that (he pretended) was the ultimate disgrace!</blockquote><br />
The above extract is from the excellent "<a href="http://www.google.com/search?q=man+who+loved+only+numbers">The Man Who Loved Only Numbers</a>"<br />
<br />
I laughed quite hard when I read this :)Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-82352159324892223702011-10-01T17:15:00.000+01:002012-12-12T11:04:53.671+00:00logarithm of large number - it is not about computation!Computer programmers who have not studied Mathematics beyond elementary level, often trip over this one.<br />
<br />
Perhaps you asked yourself one of these questions:<br />
<blockquote>Why does Gnu Gmp library not have a logarithm function?</blockquote><br />
<blockquote>What is the natural log of a large number such as 6775471000000000?</blockquote><br />
<br />
<b>Rules of logs - product and powers:</b><br />
<br />
For calculating logarithms of gigantic numbers - the standard ANSI C library is probably all that you need.<br />
<br />
That computational tool, needs to be supplemented, with two pieces of Mathematical knowledge as illustrated here:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7pgbXS6PzUT9qCR06BtRWn1ICgr5PNsfCNTJP1InTVDVOMJnbLuiFYW4nyt9apHQi_WFqZDdB-89IsK-6wXQOr7D7cdBBHRa0uHQTROc1gepE1NcBPvzhWsF3aN5-wHEhRHMZLpHzFUt6/s1600/wikipediaLogarithmProductRule-452f11536c02c2635a8b31d6955d36cd__2011Q3creativeCommons.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7pgbXS6PzUT9qCR06BtRWn1ICgr5PNsfCNTJP1InTVDVOMJnbLuiFYW4nyt9apHQi_WFqZDdB-89IsK-6wXQOr7D7cdBBHRa0uHQTROc1gepE1NcBPvzhWsF3aN5-wHEhRHMZLpHzFUt6/s1600/wikipediaLogarithmProductRule-452f11536c02c2635a8b31d6955d36cd__2011Q3creativeCommons.jpeg" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhay1qvSa4vAj0XhXwEQVrl35RF9HSfXj-zIeatQB-ABBFAVeZwhRONapwq_5osq7HYlFfPCkRm-uMNR9qkaI6d4oO3iU1ft3yhSAjrnBi899iquCy3Mb-MOlbGmykV0Vg7kJArTCr5B-uL/s1600/wikipediaLogarithmPowerRule-bae5cfa28008309b34f05f6536ac9cba__2011Q3creativeCommons.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhay1qvSa4vAj0XhXwEQVrl35RF9HSfXj-zIeatQB-ABBFAVeZwhRONapwq_5osq7HYlFfPCkRm-uMNR9qkaI6d4oO3iU1ft3yhSAjrnBi899iquCy3Mb-MOlbGmykV0Vg7kJArTCr5B-uL/s1600/wikipediaLogarithmPowerRule-bae5cfa28008309b34f05f6536ac9cba__2011Q3creativeCommons.jpeg" /></a></div><br />
<br />
<div style="text-align: right;"><span style="font-size: x-small;">Images courtesy of <a href="http://en.wikipedia.org/wiki/Logarithm#Product.2C_quotient.2C_power.2C_and_root">Wikipedia</a> (Creative Commons Licensed)</span></div><br />
The number I mentioned above 6775471000000000 is too large for entry into a school standard calculator. Ten digits or so is the most you can enter.<br />
<br />
Rewrite the number as 6775471 times 'a thousand million' and go that way.<br />
<br />
Using the product of logs rule (graphic above) and doing the two calculations we see that:<br />
<br />
log(6775471) = 15.728819 to 6 decimal places<br />
<br />
...and...<br />
<br />
log(1,000,000,000) = 20.723266 to 6 decimal places<br />
<br />
Add the two answers together gives <span style="font-size: large;"><b>36.452085</b></span> to 6 decimal places<br />
<br />
Alternatively for the second piece of the addition you could have used 9log(10) by utilising the second rule - power of logs.<br />
<br />
<br />
<b>But my number is huge and does not contain a long stream of zeros?</b><br />
<br />
This is all about precision. Do you really need more than say 6 or 8 decimal places?<br />
<br />
Avoid creating artificial conditions. Unless you are working with <a href="http://www.wikipedia.org/wiki/Numerical_analysis#The_generation_and_propagation_of_errors">numerical methods</a> and/or in Engineering, then you will probably answer NO to what I just asked.<br />
<br />
So your number is 6775471 followed by another 75 digits (some zero some not)<br />
<br />
If you only need 6 digits of precision in your answer, then it matters not what those 75 digits contain, simply pretend they are zero, and either adapt my method shown or...<br />
<br />
...use the 2nd log rule from the image above.
<br />
( hint: You might want to use 75log(10) as part of your workings. ) <br />
<br />
Answer Guess: Around 187.nnnnnn sounds about right.<br />
<br />
<br />
<b>Prime number searching should not be limited to just Mathematicians</b><br />
<br />
Agreed.<br />
<br />
However looking up some rules of logarithms by reading this page or <a href="http://www.wikipedia.org/wiki/Logarithm#Product.2C_quotient.2C_power.2C_and_root">looking on Wikipedia</a> is not hard.<br />
<br />
So quit moaning that 'such and such a library' does not have a function for logarithms of huge integers, and take five minutes to do a little addition and subtraction.<br />
<br />
Often Ansi C coders first go searching for log() of huge integer functions, when they are writing prime number search programs, which is why I mention it.<br />
<br />
<br />
<b>Notes and Further Reading:</b><br />
<br />
Laws of Logarithms is part of the "Core 2 (C2)" Curriculum for post compulsory education in the UK (A level) .<br />
<br />
If you studied Engineering at University, then you will have encountered Laws of Logarithms twice - once as part of 'A Level' Mathematics, and once as part of your Engineering course.<br />
<br />
All the Logarithms in this article are 'Natural Log'. Your calculator might show that as 'ln' depending on the brand.<br />
<br />
The Laws of Logarithms apply similarly to base 10 logs - but you would obtain different decimal answers, than those tabulated above.<br />
<br />
<ul><li><a href="http://www.google.com/search?q=laws+of+logarithms+worksheet">Laws of Logarithms worksheet - websearch</a></li>
<li><a href="http://www.amazon.co.uk/Edexcel-AS-Level-Modular-Mathematics/dp/0435519115">C2 Core 2 Mathematics Book</a> - Pledger & Wilkins [ amazon.co.uk ]</li>
</ul>The <a href="http://www.amazon.co.uk/Edexcel-AS-Level-Modular-Mathematics/dp/0435519115#reader_0435519115">Index page</a> for that C2 book shows pages 43 and 44 cover 'multiplication law' & 'power law' for Logarithms.Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-62900326847131428882011-09-23T12:54:00.001+01:002011-09-23T13:00:57.092+01:00log theory reminder - pari / gp usefulWhen working with a scientific calculator that has log to base e and log to base 10 only, employ 'Change of Base' theory.<br />
<br />
<b>Change of Base - Wikipedia</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKot5J2sEGEKeKaPLonNzzQxgybhWuQD2SIm-LH35Mdy6y6Z3SSrleDa5JKJYWPbMvmy6IcXPNEkSej-e1i5glICI9bDp_sIFxKYodL1qy31YJe1T2l9kp4Xjh9NOxk9HFg4WEwN8MRr6J/s1600/wikipediaChangeOfBase__20110923creativeCommons-d4d346dc72868bcc2aa98c0bf3995068.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKot5J2sEGEKeKaPLonNzzQxgybhWuQD2SIm-LH35Mdy6y6Z3SSrleDa5JKJYWPbMvmy6IcXPNEkSej-e1i5glICI9bDp_sIFxKYodL1qy31YJe1T2l9kp4Xjh9NOxk9HFg4WEwN8MRr6J/s1600/wikipediaChangeOfBase__20110923creativeCommons-d4d346dc72868bcc2aa98c0bf3995068.png" /></a></div><br />
Source: http://www.wikipedia.org/wiki/Logarithm#Change_of_base<br />
<br />
<br />
<b>Change of Base - questions rewritten:</b><br />
<br />
If you know even a little about logs then you should be able to answer the following question:<br />
<br />
<blockquote>What is log to base 10 of 1000?</blockquote>The blindingly obvious answer is <b>three</b>.<br />
<br />
Here are two additional ways of phrasing things to get an answer:<br />
<ul><li>To what power do we raise 10 so as to obtain 1000</li>
<li>How many zeros in 1000</li>
</ul><br />
Assuming your calculator only does natural log (log to base e) use Change of base:<br />
<br />
<div align="center">log to base 10 of 1000 is (log to base e (1000))/(log to base e (10)) = <b>3</b></div><br />
<br />
<b>Pari / GP - an example using x=1+1365*2^15</b><br />
<br />
Pari / GP is a number theory program. It is designed for working Mathematicians / Number theorists, and is most useful to folks comfortable with Mathematical theory.<br />
<br />
It is not designed, primarily, as a 'user friendly calculator replacement' for lay folks.<br />
<br />
Now using x as given above - what is log to base 2 of x?<br />
<br />
Answer:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPIFieubUfeLv_kJx-9GY03bvJ12XJPBMVgMdnXEbxx6vZ3K1TnvEyqigfzn-Pqu7JdcaUB2MfqXGzpH8EFtN0opJP6RQKw7RaTDi0Bvb34LZgwTaTCBz4Wsd22XpfrZQZiSEe2opybI91/s1600/parigpChangeOfBase__2011Q3gnumbersPublishedExample.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPIFieubUfeLv_kJx-9GY03bvJ12XJPBMVgMdnXEbxx6vZ3K1TnvEyqigfzn-Pqu7JdcaUB2MfqXGzpH8EFtN0opJP6RQKw7RaTDi0Bvb34LZgwTaTCBz4Wsd22XpfrZQZiSEe2opybI91/s1600/parigpChangeOfBase__2011Q3gnumbersPublishedExample.jpeg" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh84ZDgEwfBXjCcZ6qV9-NinwgXcFVr63EcfjH9H1e8x_eMxjVzweJqVKp136fMON3C6uEEZaluNmq5UOsVLxrvW8UeX9oVa-GAnEY1k5SEY0sgFUR0_zznPnam-L5bBJRy1JMUfBABAOpU/s1600/parigpChangeOfBase__2011Q3gnumbersPublishedExamplePariGP.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh84ZDgEwfBXjCcZ6qV9-NinwgXcFVr63EcfjH9H1e8x_eMxjVzweJqVKp136fMON3C6uEEZaluNmq5UOsVLxrvW8UeX9oVa-GAnEY1k5SEY0sgFUR0_zznPnam-L5bBJRy1JMUfBABAOpU/s1600/parigpChangeOfBase__2011Q3gnumbersPublishedExamplePariGP.jpeg" /></a></div><br />
<br />
<br />
<br />
If you want that Answer as a continued fraction then <a href="http://www.wolframalpha.com/input/?i=log2%2844728321%29">Wolfram Alpha can do that</a>.Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-61063913814484834152011-09-21T11:13:00.000+01:002011-09-21T11:13:25.164+01:00Introduce a little Geometry into your life - morningWhat is not to like about Geometry ... it surrounds us, so why not embrace it?<br />
<br />
<a href="http://www.royalstone.ca/poolgallery.html">Patios & Pools</a> to <a href="http://www.stonebydesign.ca/">Steps & Walkways</a> and beyond.<br />
<br />
Have fun and introduce a bit of Geometry into your day!<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlLoFM4VYawP7AX1VXleZPbqYO5Pdl8JAn7rVnKib3Gu8LBFGPHmkE5k-dSDBME5tGyv9kDtG8Va7otNjIccM67b-Rx1lx-eKdHPUaxJbg296gKqvjw_1LjrOj979Zfh4X-or1VZIvgHhs/s1600/geometricToast__20110921gnumbers.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlLoFM4VYawP7AX1VXleZPbqYO5Pdl8JAn7rVnKib3Gu8LBFGPHmkE5k-dSDBME5tGyv9kDtG8Va7otNjIccM67b-Rx1lx-eKdHPUaxJbg296gKqvjw_1LjrOj979Zfh4X-or1VZIvgHhs/s400/geometricToast__20110921gnumbers.jpeg" width="303" /></a></div>Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-77102054407391165002011-08-31T11:46:00.000+01:002011-08-31T11:46:20.484+01:00Counter examples as Mnemonics - RemaindersWhen refreshing my memory about a Mathematical subject - I find counter examples can be a useful way of getting active. Here is an example about mod() / Congruences.<br />
<br />
Working mod 4 with two numbers a=5 and b=7<br />
<br />
...and writing in computing function form we say...<br />
<br />
mod(a,4) = 1<br />
<br />
and<br />
<br />
mod(b,4) = 3<br />
<br />
Now apply a scaling (k) to both numbers ... say ... scaling by 11<br />
<br />
mod(ka,4) = 3 (ka is 55)<br />
<br />
and<br />
<br />
mod(kb,4) = 1 (kb is 77)<br />
<br />
<br />
And what we observe is that the results seem to have exchanged places :)<br />
<br />
This counter example is a good reminder that applying the same scaling to two different numbers does not always preserve the mod result.<br />
<br />
There is much theory to access regarding congruences / modulo, and counter examples like this, can be a good way of stimulating a refresher of that theory.<br />
<br />
Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-89266074626279934132011-08-21T14:32:00.000+01:002011-08-21T14:32:00.303+01:00The death of week numbers - and browser helpUsed to be a time when workers in offices had week numbers marked at the bottom of the page, of a desktop paper diary.<br />
<br />
Managers and others with budget responsibilities found these particularly useful<br />
<br />
Now folks are using smartphone calendars, Google calendars, or <a href="http://www.mozilla.org/projects/calendar/lightning/system-requirements.html">Lightning</a> to help with their planning.<br />
<br />
<br />
<strong>Marathon preparation - 12 weeks or so right?</strong><br />
<br />
Question: When do I need to start my running preparation if my Marathon is 1st December?<br />
<br />
The simple answer is <strong>48-12 = week commencing 5th September</strong> .... but some images make it clearer.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVZm049ykFrknVFFhpTsLoaAVAnE3vq8WhlDpOxtMXJiGmluC8FwliB38rsHfpCL0RYuaYpsSNjR_2TcWlQD7YtqZGCMYJVY7O3aW37KUSi-dqYtTbDYcMtBEsPOyo-aJTPi5_EesMmSCG/s1600/weeksCountingBackwards-TheCmdlineWay__20111201back12weeksAnnotated.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVZm049ykFrknVFFhpTsLoaAVAnE3vq8WhlDpOxtMXJiGmluC8FwliB38rsHfpCL0RYuaYpsSNjR_2TcWlQD7YtqZGCMYJVY7O3aW37KUSi-dqYtTbDYcMtBEsPOyo-aJTPi5_EesMmSCG/s1600/weeksCountingBackwards-TheCmdlineWay__20111201back12weeksAnnotated.jpeg" /></a></div><br />
...and for folks who live in a web browser rather than at the command line ...<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEagu8VF7TazTie9s8bazzFj_DDigEk64HRFDtnTkO4k6cZeuOmYhetCKU2KUNq0n2TjkiY7HhU4g13RzxVuY-t9WHpgeTURV7qlAw636u-kvPCsHLqB0vXuO-OgbKn7pyIctNKWsxmJj4/s1600/weeksCountingBackwards-TheWebBrowserWay__20111201back12weeks.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEagu8VF7TazTie9s8bazzFj_DDigEk64HRFDtnTkO4k6cZeuOmYhetCKU2KUNq0n2TjkiY7HhU4g13RzxVuY-t9WHpgeTURV7qlAw636u-kvPCsHLqB0vXuO-OgbKn7pyIctNKWsxmJj4/s1600/weeksCountingBackwards-TheWebBrowserWay__20111201back12weeks.jpeg" /></a></div><br />
<br />
<br />
Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-38916436430330916892011-08-17T16:01:00.002+01:002012-04-21T13:37:06.577+01:00gmp mpz gotchas - part 1The GNU mp (gmp) library is a fast and stable library for working with large integers.<br />
<br />
As with all software, when you begin using it, you find out things that you should and shouldn't do.<br />
<br />
<br />
<b>NULL arguments to functions - check for each function:</b><br />
<br />
mpz_get_str() is a function which seems to handle a NULL first argument just fine.<br />
<br />
Example function call:<br />
<br />
<pre><span style="font-size: large;">outM = mpz_get_str(NULL,10,M);</span></pre>
<br />
<div align="center">
<span style="font-size: x-small;">(outM above is a <a href="http://www.wikipedia.org/wiki/Pointer_%28computing%29#C_and_C.2B.2B">char pointer</a> and gets the decimal representation of mpz M)</span></div>
<br />
In the documentation, the function signature for mpz_get_str() is given as:<br />
<br />
<span style="font-family: "Courier New","Courier",monospace;">char * mpz_get_str (char *str, int base, mpz_t op )</span><br />
<br />
Second example - be careful what you assume!<br />
<br />
<span style="font-family: "Courier New","Courier",monospace;">if (mpz_mod_ui(NULL,C,6) == 0) { /* do something */ }</span><br />
<br />
The above throws a runtime error - not surprising when you consult the documentation for the function signature.<br />
<br />
<span style="font-family: "Courier New","Courier",monospace;">unsigned long int mpz_mod_ui (mpz_t r, mpz_t n, unsigned long int d ) </span><br />
<br />
mpz_mod_ui() is quite clear that the first argument should be an mpz type, so don't disappoint it :)<br />
<br />
When working with gmp, you are effectively working in two type spaces - C and native gmp types. Functions such as mpz_mod_ui() are really flexible, in that they give you the mod() result in two different type spaces.<br />
<br />
Libraries are not mind readers, and cannot know in which type space your next line of code will be working. By giving you the result as both an <i>unsigned long int</i> and the mpz_t labeled here as r, the function is doing it's damnedest to help you out!<br />
<br />
The downside is that you may well see little point in retaining the result in the other type space.<br />
<br />
My runtime error was caused by me attempting to throw away the mpz_t result as it felt redundant.<br />
<br />
Here is my new preferred way - use an mpz_t you set up particularly for transient results.<br />
<br />
<pre><span style="font-size: large;">if (mpz_mod_ui(MOD_NULL,C,6) == 0) {</span></pre>
<pre><span style="font-size: large;"> /* flag as six multiple */</span></pre>
<pre><span style="font-size: large;">}</span></pre>
<br />
Just create your own mpz_t MOD_NULL and use it where you are not interested in keeping the result. You will need to run mpz_init(MOD_NULL) before executing the if statement illustrated.<br />
<br />
<br />
<br />
<b>Transient variables - bad coding practices to avoid:<iframe align="right" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=droidbook-21&o=1&p=8&l=bpl&asins=0201179288&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"></iframe></b><br />
<br />
In the past, I have been tempted to reuse spare variables - example:<br />
if (mpz_mod_ui(BSQR,C,6) == 0) {<br />
<br />
It is <b>bad coding practice</b> to use a seemingly proper variable, as a holder for transient data / as a dump.<br />
<br />
Using dump variables generally is not without issue, however naming the thing correctly is at least a step in the right direction :)<br />
<br />
<br />
The important thing to remember is that whatever you call your transient variable, that it is not used to hold values that really are used in your logic.<br />
<br />
Avoid the temptation to reuse a label wherever possible - it rarely leads to good things.<br />
<br />
<br />
<b>NULL as the first argument to mpz_get_str - probably going wrong here:</b><br />
<br />
Earlier I used mpz_get_str() as an example of a function that worked with NULL as a first argument.<br />
<br />
<pre><span style="font-size: large;">outBSQRM4AC = mpz_get_str(NULL,10,BSQRM4AC);</span></pre>
<br />
Knowing the function signature, and looking at the above line of code, you should be thinking <i>char pointer </i>for outBSQRM4AC.<br />
<br />
Assigning the result of mpz_get_str() using an equals symbol is okay, and you are asking the gmp library to do your allocation for you.<br />
<br />
If however, you known the maximum size of the MPZ / character array that you require, then you may prefer to predefine your character array, and tell mpz_get_str() to use it. In that case the the first argument of mpz_get_str() <b>will not</b> be NULL.<br />
<br />
If you have predefined your character array (including size, then you might instead be using a call of this form:<br />
<br />
<pre><span style="font-size: large;">mpz_get_str(outBSQRM4AC,10,BSQRM4AC);</span></pre>
<br />
<br />
<b>Notes and Further Reading:</b><br />
<br />
The publisher SAMS have a book "Teach yourself C in 24 hours"<iframe align="right" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=droidbook-21&o=1&p=8&l=bpl&asins=067231861X&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"></iframe><br />
<br />
In the Chapter "Hour 17 - Allocating Memory" there is a discussion about malloc() and free() and how to use them in conjunction with <i>character pointers<i>.</i></i><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
A more indepth volume is titled "Teach yourself C in 21 days", but it really depends on how far you want to take your C skills, as to which is the better option.<iframe align="right" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=droidbook-21&o=1&p=8&l=bpl&asins=0672324482&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"></iframe><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Neither of these books are particularly 'new', however that is one of the plus points of C, it has a stable api and a body of literature that never goes out of date.<br />
<br />
Neither of these books will teach you C++, however I have not and probably never will have, any interest in learning C++<br />
<br />
If you do, then the 'in 24 hours', probably does not come near to describing, the time that you will have to devote to becoming skilled in C++.<br />
<br />
Better C++ literature is available, if you decide ANSI C is not where you wish to spend your time.Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-51507404119376939812011-08-13T13:26:00.000+01:002011-08-13T13:26:53.787+01:00Cython - notes and gotchas - part 1Experimenting with Cython, as bringing together many variants of the same .c file, has me yearning to find a better Python / C balance.<br />
<br />
Working through tutorials and experiments, I will note anything tricky, or any easy to fall into traps.<br />
<br />
<br />
<b>TypeError: 'NoneType' object is not callable:</b><br />
<br />
Because Python is flexible, and does not insist on you declaring variables ahead of time, you may be tempted to do the same in Cython.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJEBZsgT9E3SwCaJE3FEnKDsWB6UqFX8vCsewohw3cd40rukitAs8UbL5S8hJ7I66Uxd4ySNDc01mJ3g5pd-0JeGw4ksesOrFz6Au_9KeAuvkOwDp67sGexaifs9toaaFP2SGWXplt9yRz/s1600/cythonNoneType-object_is_not_callable__20110functionNamesVariableNamesTryNotToClash.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJEBZsgT9E3SwCaJE3FEnKDsWB6UqFX8vCsewohw3cd40rukitAs8UbL5S8hJ7I66Uxd4ySNDc01mJ3g5pd-0JeGw4ksesOrFz6Au_9KeAuvkOwDp67sGexaifs9toaaFP2SGWXplt9yRz/s1600/cythonNoneType-object_is_not_callable__20110functionNamesVariableNamesTryNotToClash.jpeg" /> </a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div>Better to declare the variable 'primes' explicitly, or to avoid name clashes.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKMhki_lcFNeKECJBZFrDMISQWvNLf8iecHrH3M0n8DwHwwYnVilNoCjm45cPMqSIERrld0h-Vhydxit3mfDAT-wJEt4B0A7HGLipYGe-Wzt-vUGLZIXJI1Vkwmwh6vb1hvCkvrfFy_z0u/s1600/cython__201108functionNamesVariableNamesEitherDeclareOrTryNotToClash.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKMhki_lcFNeKECJBZFrDMISQWvNLf8iecHrH3M0n8DwHwwYnVilNoCjm45cPMqSIERrld0h-Vhydxit3mfDAT-wJEt4B0A7HGLipYGe-Wzt-vUGLZIXJI1Vkwmwh6vb1hvCkvrfFy_z0u/s1600/cython__201108functionNamesVariableNamesEitherDeclareOrTryNotToClash.jpeg" /></a></div><br />
So in the second example the result of the function call ends up in 'primes_list_strings' and we work on it from there.<br />
<br />
To clarify the original error: Calling the variable that holds the result 'primes', and making a function call to primes() in the same line, might lead to confusion.<br />
<br />
<br />
<b>Notes and Further Reading:</b><br />
<br />
If you want completion features when working with Python, then one solution is to invoke iPython and use that.<br />
<br />
There are several full IDEs for Python including <a href="http://packages.debian.org/stable/idle">Idle</a> and <a href="http://packages.debian.org/stable/eric">Eric</a>, but if you just need a little completion (and syntax highlighting), then iPython is okay also.<br />
<br />
<ul><li><a href="http://ipython.org/ipython-doc/stable/interactive/tutorial.html">Ipython - an introduction</a> [ ipython.org ]</li>
</ul><br />
Screenshot of Eric from <a href="http://screenshots.debian.net/package/eric">screenshots.debian.net</a>:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://screenshots.debian.net/screenshots/e/eric/2169_large.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://screenshots.debian.net/screenshots/e/eric/2169_large.png" /></a></div><br />
Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0tag:blogger.com,1999:blog-8621179391384256477.post-29075637245269816542011-06-26T01:07:00.002+01:002011-06-28T00:49:43.993+01:00how many bits - are you 32 bit or 64 bitMy laptop usually has a 32 bit GNU / Linux install and a 64 bit install also.<br />
<br />
It pays to remember which you are logged into when using openpfgw<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">-su: ./pfgw64: cannot execute binary file</span><br />
<br />
The answer as to why you might get that response is simple, however it is easy to mistake the symptom.<br />
<br />
Running off and websearching 'cannot execute binary file', was the wrong thing to do, and assuming that 'su' was somehow broken was a red herring.<br />
<br />
Logging into a console <u>as root</u> and running ./pfgw64 gives a more meaningful:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;">-bash: ./pfgw64: cannot execute binary file</span><br />
<br />
...which should be enough to tell you that the problem is not 'su', which in my case is just sitting in front of bash and relaying the message.<br />
<br />
I hinted at the real cause earlier. Running ./pfgw32 will see a better result, because you are logged into a <b>32 bit</b> system!<br />
<br />
It is great that openpfgw provide optimised binaries for 32 bit and 64 bit, and it is up to you, as the user, to select the correct one!<br />
<br />
Remember that openpfgw will also needs some libgmp libraries in order to run, otherwise expect a complaint about a missing .so file.Garyhttp://www.blogger.com/profile/17485264462243138001noreply@blogger.com0