BCMath programming hints for number theorists

Introduction

Here are some hints arising from my experience with programming number theory algorithms in BCMath.
The discussion is aimed at BC programmers who wish to convert their BC programs into BCMath, thereby making their BC programs more accessible.
My BC programs are located via http://www.numbertheory.org/gnubc/gnubc.html
Only a modicum of PHP programming knowledge is required and I found the book PHP for the world wide web by Larry Uhlman, a good introduction to PHP.
Matt Zandstra's book SAMS Teach Yourself PHP4 in 24 Hours is also quite readable.

Some remarks about BCMath

There is little online information about the use of the BCMath functions and just what features of BC programming go over to BCMath. Here are some of my observations:

Listing the members of a cartesian product of integers

See recursive construction of the cartesian product at
http://stackoverflow.com/questions/2516599/php-2d-array-output-all-combinations

preg_split() converts the string $Mvalue of integers which were entered separated by (any number of) spaces, into a normal array $a of $t=$count($a) numbers $a[0],...,$a[$n], where $n=bcsub($t,"1").

Debugging your BCMath script

Just as in debugging a Latex document, debugging a BCMath script can be challenging.

Please email any comments or suggestions to Keith Matthews
Last modified 9th August 2017

Return to main page