# Verse of the Day

## about w3 spec for MathML

View Source in order to see how mathML is done for simple algebra. every modern browser supports it now (sometimes I have seen misrendering though circa 2014).

I need to say to folks out there that the word "Math" covers the plural instance. much to my dismay, I have often seen lately (past several years) the word "maths". this is not a proper term in English. "math" covers both singular and plural, but in the plural usage of the singular form you just describe it differently. There are a number of those words in English.

## motivation

let me first say that I am not a mathematician and I do not wish to become one. I am primarily a Software Engineer who likes optimized algorithms. I know some of algebra, and my calculus skills have reduced to near 0, but I do try to keep upon what skills I have. once in a while I see a need for calculus. I don't think I need to go that far, the uses I have for it so far someone else can handle.

RE:gcc. gcc 6.0 has some bad bugs. gcc 5.0 for some reason won't let me use fstream and throws a compile error saying "ifstream,ofstream not declared" even if I specifically include those. so if I need output, I can simply use shell redirection like `pf -10 10 -10 10 -10 10 1 10 > pf.txt`. I lack the \$\$\$ to buy visual studio (but hey, license being what it is, I also want to provide source, and the license so far doesn't allow me to do that for VC++, though I like the compiler's feature set - for multithreading users (functions can be set up to be a thread), VC++ is a must, since it auto-uses OpenCL or CUDA or something like that, with the appropriate switches like `/qpar /qvec`.

Auto-Parallelization and Auto-Vectorization in VC++. for gcc, its options don't work as well. you can't use -O4 with that sort of feature, the libraries are manually parallelized as far as `#include` and usage where you must specify wholly different filepaths for the libraries which are implemented, and it only supports you specifying the number of threads on the commandline. see the gcc manual for the list of commandline switches you can use.

`g++ -std=c++11 -lstdc++ -W -Wall -v -s -static -O2 -fopenmp -lgomp -floop-parallelize-all -ftree-loop-vectorize -ftree-slp-vectorize -O2 -floop-nest-optimize -opf.exe pf.cpp`

I do not want to become a govt employee or a mathematician, since my services are for God at this point. There may be some practical uses for Fermat's Last Theorem. I may Enter this into a mathematics journal at some point.

This math should be viewed with firefox, which renders MathML best.

## Pierre de Fermat's Last Theorem

Pierre de Fermat said "I have a marvellous proof, but it does not fit in the margin." This quote leads me to believe the solutions out there I have read about do not fit this qualification. ~500 pages is too long of a solution I suspect to fit Fermat's quote.

I tried to solve this circa 2014-2015. I would guess that the proof may have fit one 1-2 pages or so.

I found that at the current time, his qualification that integerss were to be used causes me to need fixed point calculations which I do- not have (so either Boost will have to make their fixed point class available in c++ or I have to write one, and my head is swimming after trying to write one. it's not as simple as doing long division. the problem is the digits are 32 bits wide maximum, and multiplies cause rthe need for 64 bits, and calculating digit position values without a BigInt class is impossible. and I don't think I can do it. I can't resolve the requirement for all the bits to be available during power calculations and multiples and adds while getting digit position multiplier values for input and output.

Both Boost and Gnu GMP is not available to the mingw-w64 (gcc for windows) compiler either.

But decimal128 is, and I want to see if I can use it here for getting results. it probably doesn't have enough bits to do the job because the fractional part is probably 1/2 the bits with the dp right in the middle. 20^20=104,857,600,000,000,000,000,000,000≤(2^88/2) and 10^10=10,000,000,000≤/(2^35/2)

maybe I can get by with uintmax_t (64-bit currently) and use C/C++'s overflow and underflow to simulate fixed point.

I have a problem to solve: the current answer I got was that x*y=z or x*y-z=0 and 2*5-10=0 2^3*5^3-10^3=0 yet 2^3+5^3-10^3!=0 (=-867)

$x^k+y^k=z^k where integer k>=1, x>=1, y>=1, z>=1$ It can be rewritten as a sum if that helps anyone. $z^k=Σ(i=1,2,x[i]^k)$

```manual method examples to try using combinatorics,
counting with &inf; number base per digit (or number) column.

pf -o pf.txt 1 40 1 40 1 40 3 40
unit test of uintmaxpow(2,63) 2^63=0 should be big: no overflow error
ERROR: 1548056 overflows after good results
done. 0 data rows, maxBitsOverflow=64

```

answers do exist, and they are not hard to find. but finding a pattern or set of properties which describe this equation are difficult to guess at without a further solve for k.

the problem is the proof. a CAS doesn't seem to solve this kind of problem.

## my solution to fermat's last theorem circa 2014-2015

using an hp-50g calculator's solve:
$x={\text{e}}^{\frac{\text{ln}\left(-\left({\text{e}}^{k×\text{ln}\left(y\right)}-{\text{e}}^{k×\text{ln}\left(z\right)}\right)\right)+2·i·\mathrm{n1}·\pi }{k}}$
and by hand:
$x^k+y^k=z^k$ $x^k+y^k=z^k where integer k>=1, x>=1, y>=1, z>=1$
and solving for k
$x^k+y^k=z^k$

```x^k-z^k+y^k=0
using x^k=k*log x:
k*log(x)-k*log(z)+k*log(y)
factor:
k*(log(x)-log(z)+log(y))=0
divide both sides by k:
k*(log(x)-log(z)+log(y))/k=0/k
reduce:
log(x)-log(z)+log(y)=0
simplify:
log(x)+log(y)-log(z)=0
and the above could be the key that unlocks something.
this explains a relationship/property so far.
log(x)+log(y)=log(z)
2nd try to solve for k wound up with a dead end:
log(x)+log(y)-log(z)=0
log(x^k+y^k)=log(z^k)
```
$\text{log}\left({x}^{k}+{y}^{k}\right)=\text{log}$
```log(x^k+y^k)=k*log(z)
log(x^k+y^k)/log(z)=k
```
$\text{log}\left({x}^{k}+{y}^{k}\right)\text{log}$
```log(10^(k*log(x))+10^(k*log(y)))/log(z)=k
a recursive definition and seemingly a dead end.
```
$y=e^((ln(-(e^(k*ln(x))-e^(k*ln(z))+2*i*n1*pi))/k) strangeness on rt side due to problem with hp50g SOLVE()$
$z=k*log(x^k+y^k)$
solve for z:
$x^k+y^k=z^k$
$log(z^k)=log(x^k+y^k)$
$k*log(z)=log(x^k+y^k)$
$log(z)=log(x^k+y^k)/k$
$10^log(z)=10^(log(x^k+y^k)/k)$
$z=10^(log(x^k+y^k)/k)=e^(ln(x^k+y^k)/k)$
and solving for k (failed with what I have available in my 30-yr-old old math book):
```fermat's last theorem
x^k+y^k=z^k, k is integer
subtract z^k from both sides
x^k+y^k-z^k=0
use log(x^y)=y*log(x)
k*log(x)+k*log(y)-k*log(z)=0
divide by k on both sides
k*log(x)/k+k*log(y)/k-k*log(z)/k=0/k
this spikes when you hit k=0 though.
so something should be noted that k=0->&inf;
cross out the canceled k's
log(x)+log(y)-log(z)=0
interesting property.
using log[b](m*n)=log[b](m)+log[b](n)
log(x)+log(y)-log(z)=0
log(x*y)-log(z)=0
log(x*y)=log(z)
interesting property.
10^x both sides
x*y=z
```

$log(z^k)=log(x^k+y^k)$
$z=10^(ln(e^(k*ln(y))+e^(k*ln(x))+2*i*n1*pi)/k)$
and solving for k:
well, the 50g gave the error "/!\ SOLVE ERROR: Not reducible to a rational expression". my guess was that the answer involves the set of prime numbers for x, y, z. nope.

## properties

I know from computer tests that FLT (Fermat's Last Theorem) has some very simple properties:

• k≥1, x≥1, y≥1, z≥1, x≤y
• it's odds and evens. if x+y MOD 2=0 (even), z MOD 2=0 (z is even).
• x usually ≠ y usually ≠ z
```x+y is incremental with x+y>=2.
x+y+z is incremental by 2 with x+y+z>=4 and is even.
x+y+z+k is incremental by 2 with x+y+z+k>=5 and is odd if k is odd (so far, need GMP)
because k at any doubled power.
this goes up to 20 for each variable.

C:\jim>echo on
C:\jim>g++ -O4 -W -Wall -static -lstdc++ -std=c++11 -o pf.exe pf.cpp
C:\jim>pf.exe 20 20 20 1 20 1
unit test of int64pow(2,62) 2^62=4611686018427387904 should be big
[x,y,z,k]
[1,1,2,1],x+y=2odd=0,x+y+z=4odd=0,x+y+z+k=5odd=1
[1,2,3,1],x+y=3odd=1,x+y+z=6odd=0,x+y+z+k=7odd=1
[1,3,4,1],x+y=4odd=0,x+y+z=8odd=0,x+y+z+k=9odd=1
[1,4,5,1],x+y=5odd=1,x+y+z=10odd=0,x+y+z+k=11odd=1
[1,5,6,1],x+y=6odd=0,x+y+z=12odd=0,x+y+z+k=13odd=1
[1,6,7,1],x+y=7odd=1,x+y+z=14odd=0,x+y+z+k=15odd=1
[1,7,8,1],x+y=8odd=0,x+y+z=16odd=0,x+y+z+k=17odd=1
[1,8,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[1,9,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[1,10,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[1,11,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[1,12,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[1,13,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[1,14,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[1,15,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[1,16,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[1,17,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[1,18,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[1,19,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[2,1,3,1],x+y=3odd=1,x+y+z=6odd=0,x+y+z+k=7odd=1
[x,y,z,k]
[2,2,4,1],x+y=4odd=0,x+y+z=8odd=0,x+y+z+k=9odd=1
[2,3,5,1],x+y=5odd=1,x+y+z=10odd=0,x+y+z+k=11odd=1
[2,4,6,1],x+y=6odd=0,x+y+z=12odd=0,x+y+z+k=13odd=1
[2,5,7,1],x+y=7odd=1,x+y+z=14odd=0,x+y+z+k=15odd=1
[2,6,8,1],x+y=8odd=0,x+y+z=16odd=0,x+y+z+k=17odd=1
[2,7,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[2,8,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[2,9,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[2,10,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[2,11,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[2,12,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[2,13,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[2,14,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[2,15,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[2,16,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[2,17,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[2,18,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[3,1,4,1],x+y=4odd=0,x+y+z=8odd=0,x+y+z+k=9odd=1
[3,2,5,1],x+y=5odd=1,x+y+z=10odd=0,x+y+z+k=11odd=1
[3,3,6,1],x+y=6odd=0,x+y+z=12odd=0,x+y+z+k=13odd=1
[x,y,z,k]
[3,4,7,1],x+y=7odd=1,x+y+z=14odd=0,x+y+z+k=15odd=1
[3,5,8,1],x+y=8odd=0,x+y+z=16odd=0,x+y+z+k=17odd=1
[3,6,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[3,7,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[3,8,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[3,9,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[3,10,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[3,11,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[3,12,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[3,13,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[3,14,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[3,15,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[3,16,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[3,17,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[4,1,5,1],x+y=5odd=1,x+y+z=10odd=0,x+y+z+k=11odd=1
[4,2,6,1],x+y=6odd=0,x+y+z=12odd=0,x+y+z+k=13odd=1
[4,3,7,1],x+y=7odd=1,x+y+z=14odd=0,x+y+z+k=15odd=1
[4,4,8,1],x+y=8odd=0,x+y+z=16odd=0,x+y+z+k=17odd=1
[4,5,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[4,6,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[x,y,z,k]
[4,7,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[4,8,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[4,9,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[4,10,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[4,11,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[4,12,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[4,13,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[4,14,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[4,15,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[4,16,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[5,1,6,1],x+y=6odd=0,x+y+z=12odd=0,x+y+z+k=13odd=1
[5,2,7,1],x+y=7odd=1,x+y+z=14odd=0,x+y+z+k=15odd=1
[5,3,8,1],x+y=8odd=0,x+y+z=16odd=0,x+y+z+k=17odd=1
[5,4,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[5,5,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[5,6,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[5,7,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[5,8,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[5,9,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[5,10,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[x,y,z,k]
[5,11,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[5,12,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[5,13,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[5,14,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[5,15,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[6,1,7,1],x+y=7odd=1,x+y+z=14odd=0,x+y+z+k=15odd=1
[6,2,8,1],x+y=8odd=0,x+y+z=16odd=0,x+y+z+k=17odd=1
[6,3,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[6,4,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[6,5,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[6,6,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[6,7,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[6,8,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[6,9,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[6,10,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[6,11,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[6,12,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[6,13,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[6,14,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[7,1,8,1],x+y=8odd=0,x+y+z=16odd=0,x+y+z+k=17odd=1
[x,y,z,k]
[7,2,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[7,3,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[7,4,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[7,5,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[7,6,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[7,7,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[7,8,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[7,9,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[7,10,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[7,11,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[7,12,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[7,13,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[8,1,9,1],x+y=9odd=1,x+y+z=18odd=0,x+y+z+k=19odd=1
[8,2,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[8,3,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[8,4,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[8,5,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[8,6,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[8,7,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[8,8,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[x,y,z,k]
[8,9,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[8,10,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[8,11,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[8,12,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[9,1,10,1],x+y=10odd=0,x+y+z=20odd=0,x+y+z+k=21odd=1
[9,2,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[9,3,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[9,4,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[9,5,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[9,6,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[9,7,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[9,8,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[9,9,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[9,10,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[9,11,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[10,1,11,1],x+y=11odd=1,x+y+z=22odd=0,x+y+z+k=23odd=1
[10,2,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[10,3,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[10,4,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[10,5,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[x,y,z,k]
[10,6,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[10,7,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[10,8,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[10,9,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[10,10,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[11,1,12,1],x+y=12odd=0,x+y+z=24odd=0,x+y+z+k=25odd=1
[11,2,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[11,3,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[11,4,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[11,5,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[11,6,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[11,7,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[11,8,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[11,9,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[12,1,13,1],x+y=13odd=1,x+y+z=26odd=0,x+y+z+k=27odd=1
[12,2,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[12,3,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[12,4,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[12,5,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[12,6,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[x,y,z,k]
[12,7,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[12,8,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[13,1,14,1],x+y=14odd=0,x+y+z=28odd=0,x+y+z+k=29odd=1
[13,2,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[13,3,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[13,4,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[13,5,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[13,6,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[13,7,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[14,1,15,1],x+y=15odd=1,x+y+z=30odd=0,x+y+z+k=31odd=1
[14,2,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[14,3,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[14,4,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[14,5,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[14,6,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[15,1,16,1],x+y=16odd=0,x+y+z=32odd=0,x+y+z+k=33odd=1
[15,2,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[15,3,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[15,4,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[15,5,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[x,y,z,k]
[16,1,17,1],x+y=17odd=1,x+y+z=34odd=0,x+y+z+k=35odd=1
[16,2,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[16,3,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[16,4,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[17,1,18,1],x+y=18odd=0,x+y+z=36odd=0,x+y+z+k=37odd=1
[17,2,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[17,3,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[18,1,19,1],x+y=19odd=1,x+y+z=38odd=0,x+y+z+k=39odd=1
[18,2,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[19,1,20,1],x+y=20odd=0,x+y+z=40odd=0,x+y+z+k=41odd=1
[3,4,5,2],x+y=7odd=1,x+y+z=12odd=0,x+y+z+k=14odd=0
[4,3,5,2],x+y=7odd=1,x+y+z=12odd=0,x+y+z+k=14odd=0
[5,12,13,2],x+y=17odd=1,x+y+z=30odd=0,x+y+z+k=32odd=0
[6,8,10,2],x+y=14odd=0,x+y+z=24odd=0,x+y+z+k=26odd=0
[8,6,10,2],x+y=14odd=0,x+y+z=24odd=0,x+y+z+k=26odd=0
[8,15,17,2],x+y=23odd=1,x+y+z=40odd=0,x+y+z+k=42odd=0
[9,12,15,2],x+y=21odd=1,x+y+z=36odd=0,x+y+z+k=38odd=0
[12,5,13,2],x+y=17odd=1,x+y+z=30odd=0,x+y+z+k=32odd=0
[12,9,15,2],x+y=21odd=1,x+y+z=36odd=0,x+y+z+k=38odd=0
[12,16,20,2],x+y=28odd=0,x+y+z=48odd=0,x+y+z+k=50odd=0
[x,y,z,k]
[15,8,17,2],x+y=23odd=1,x+y+z=40odd=0,x+y+z+k=42odd=0
[16,12,20,2],x+y=28odd=0,x+y+z=48odd=0,x+y+z+k=50odd=0
ERROR: overflow
done.
```

## computer test for a set of values using C++ and int64_t for an integer type:

```/*
Author: Jim Michaels
Abstract: Pierre de Fermat's Last Theorem tests
Created: 3-23-2016
Current Date: 3-23-2016
Instructions for mingw-w64:
files/Toolchains pargeting Win64/Personal%20Builds/dongsheng-daily/5.3.1-20160318
files/Toolchains pargeting Win32/Personal%20Builds/dongsheng-daily/5.3.1-20160318
1. extract compiler using 7-zip (7-zip.org) to root directory (c:\) of hard drive
2. in windows, start cmd shell with [windows-logo-flag-key]-R cmd [Enter]
type the following into a batch file and save it as build.cmd:
rem delete old executable so compile will be successful
rem sometimes fails if file exists depending on compiler.
del pf.exe
rem if path doesn't contain this filepath, append it or paste it.
if errorlevel 1 set notFound=true
if @%PROCESSOR_ARCHITECTURE%@==@x86@ (
path|find /i "C:\gcc-5-win32\bin"
if @%notFound%@==@true@ path=%path%;C:\gcc-5-win32\bin
) else (
path|find /i "C:\gcc-5-win64\bin"
if @%notFound%@==@true@ pathpath=%path%;C:\gcc-5-win64\bin
)
rem compile
g++ -O4 -W -Wall -static -lstdc++ -std=c++11 -o pf.exe pf.cpp
pf -o pf.txt 1 20 1 20 1 20 1 20
type pf.txt
paste it in with alt-space ep in the shell or ctrl-v
depending on if you are using notepad or edit.
5. build and run it with the command
build
this should be compilable on any computer that has a c++ compiler available
for it.
this can be converted simply for calculation but not discovery putposes
for multithreading using the four concentric for loops near the bottom
of the code. I know that since there is only 1 output (cmd shell's stdio or
pf.txt file, that would make the
std::vector would need to be parallelized using the keyword volatile, but it
would be an unordered list and make it difficult for people to handle. there
are workarounds.
I would start by using std::vector<std::string> for writing each line of output
instead of using fstream directly. then sort the array of strings.
before processing, you need to GetAvailableProcessorCount() from windows to find
out out many threads/cores there are.
code::blocks has a nice editor.
*/
#if defined(_MSC_VER)
#pragma loop(hint_parallel(n))//for VC++
#endif
#include <ios>
#include <string>
#include <fstream>
#include <iostream>//std::cout, std::cerr, std::endl, operator<<
#include <cstdint>//uint64_t
#include <cstdlib>//strtoull
#include <cstring>//_stricmp
#include <algorithm>//std::max
//config BEGIN
#define PROGRAM_DESCRIPTION "Pierre de Fermat's last theorem test"
#define PROGRAM_NAME "pf"
#define PROGRAM_VERSION "1.0"
//not using the copyright or license right now because I don't have either
typedef intmax_t BaseType;//use this type from here on out. easy to change since it's in 1 place
//use the largest integer type you can find, unsigned.
//header every 20 good rows of data output
//config END
//global variables
bool overflowErr=false,anyErr=false,toFile=false;
std::ofstream fout;
void help() {
//c/c++ can group strings together and join them
std::cout<<PROGRAM_NAME " " PROGRAM_VERSION " - " PROGRAM_DESCRIPTION<<std::endl<<
"usage: " PROGRAM_NAME " [options] [minX maxX minY maxY minZ maxZ minK maxK] > " PROGRAM_NAME ".txt"<<std::endl<<
"options:"<<std::endl<<
"  [-[-]h[elp]|/h[elp]|-[-]?|/?] gives help"<<std::endl<<
"  [-[-]v[ersion]|/v[ersion]] gives version number"<<std::endl<<
"  [-[-]o[utput]|/o[utput] filepath] sends output to a file"<<std::endl<<
#endif
#endif
"looks for numbers which fit the equation x^k+y^k=z^k"<<std::endl<<
"number arguments must be whole numbers (positive integers)."<<std::endl;
if (toFile) {
fout<<PROGRAM_NAME " " PROGRAM_VERSION " - " PROGRAM_DESCRIPTION<<std::endl<<
"usage: " PROGRAM_NAME " [options] [minX maxX minY maxY minZ maxZ minK maxK] > " PROGRAM_NAME ".txt"<<std::endl<<
"options:"<<std::endl<<
"  [-[-]h[elp]|/h[elp]|-[-]?|/?] gives help"<<std::endl<<
"  [-[-]v[ersion]|/v[ersion]] gives version number"<<std::endl<<
"  [-[-]o[utput]|/o[utput] filepath] sends output to a file"<<std::endl<<
#endif
#endif
"looks for numbers which fit the equation x^k+y^k=z^k"<<std::endl<<
"number arguments must be whole numbers (positive integers)."<<std::endl;
}
}
//c/c++ can group strings together and join them
std::cout<<PROGRAM_NAME " 2016 Jim Michaels"<<std::endl;
if (toFile) {
fout<<PROGRAM_NAME " 2016 Jim Michaels"<<std::endl;
}
}
#endif
//c/c++ can group strings together and join them
std::cout<<PROGRAM_NAME " is under the following license(s):"<<std::endl;
if (toFile) {
fout<<PROGRAM_NAME " is under the following license(s):"<<std::endl;
}
}
#endif
uintmax_t maxBitsOverflow = 0;
bool negative=false;
BaseType uintmaxpow(BaseType base, BaseType power) {
BaseType n=1,i;
if (0==power) {
return n;//1
}
if (0==base&&0==power) {//error, but don't display it
anyErr=true;
return 0; //error
}
for (i=1; i<=power && !overflowErr; i++) {//skipping 0 (1st iteration) and overflows
n*=base;
overflowErr=overflowErr||(n<base);//overflow detection
}
if (overflowErr) {
anyErr=true;
//find out how many bits overflow we went over the limit
uintmax_t nBits=0,nn=n;
while (0!=nn) {
nn>>=1;
nBits++;
}
maxBitsOverflow=std::max(maxBitsOverflow,nBits);
/*
std::cout<<"ERROR: uintmax_t overflow by "<<nBits<<" bits,k="<<power<<std::endl;
if (toFile) {
fout<<"ERROR: uintmax_t overflow by "<<nBits<<" bits,k="<<power<<std::endl;
}
*/
return 0;
}
return n;
}//BaseType uint64pow(BaseType base, BaseType power)
//argc is the argument count, argv is the argument array of C strings.
int main(int argc, char * argv[]) {
BaseType
minX=1,
maxX=20,
minY=1,
maxY=20,
minZ=1,
maxZ=20,
minK=1,
maxK=20,
k,x,y,z,
goodCount=0,
errCount=0;
//process arguments
argc--;argv++;//skip argv[0] which is the command used so argc is correct
if (argc<1) {
help();
return 0;
}
//handle commandline switches and arguments, including minK, maxK
while (argc>=1) {
if (argc>=2 && (
0==stricmp(argv[0],"--output")||
0==stricmp(argv[0],"-output")||
0==stricmp(argv[0],"/output")||
0==stricmp(argv[0],"--o")||
0==stricmp(argv[0],"-o")||
0==stricmp(argv[0],"/o")
)) {
toFile=true;
fout.open(argv[1],std::ios_base::out|std::ios_base::trunc);
if (!fout.good()) {
std::cerr<<"ERROR: -o failed to open file for writing and truncation. skipping -o switch."<<std::endl;
}
continue;
}
else
if (argc>=1 && (
0==stricmp(argv[0],"--?")||
0==stricmp(argv[0],"-?")||
0==stricmp(argv[0],"/?")||
0==stricmp(argv[0],"--help")||
0==stricmp(argv[0],"-help")||
0==stricmp(argv[0],"/help")||
0==stricmp(argv[0],"--h")||
0==stricmp(argv[0],"-h")||
0==stricmp(argv[0],"/h")
)) {
help();
continue;
}
else
if (argc>=1 && (
0==stricmp(argv[0],"--version")||
0==stricmp(argv[0],"-version")||
0==stricmp(argv[0],"/version")||
0==stricmp(argv[0],"--v")||
0==stricmp(argv[0],"-v")||
0==stricmp(argv[0],"/v")
)) {
std::cout<<PROGRAM_NAME " Version " PROGRAM_VERSION<<std::endl;
continue;
}
else
if (argc>=1 && (
0==stricmp(argv[0],"--c")||
0==stricmp(argv[0],"-c")||
0==stricmp(argv[0],"/c")
)) {
continue;
}
#endif
else
if (argc>=1 && (
0==stricmp(argv[0],"--l")||
0==stricmp(argv[0],"-l")||
0==stricmp(argv[0],"/l")
)) {
continue;
}
#endif
else
if (argc>=8) {//get all 8 parameters
minX=strtoull(argv[0],NULL,10);
maxX=strtoull(argv[1],NULL,10);
minY=strtoull(argv[2],NULL,10);
maxY=strtoull(argv[3],NULL,10);
minZ=strtoull(argv[4],NULL,10);
maxZ=strtoull(argv[5],NULL,10);
minK=strtoull(argv[6],NULL,10);
maxK=strtoull(argv[7],NULL,10);
continue;
}
else
{
std::cerr<<"ERROR: incorrect number of arguments. see " PROGRAM_NAME "--help"<<std::endl;
return 1;//return error in case someone wants to use ERRORLEVEL in a batch file.
}
}//while (argc>=1)
//do the tests. 20^20-2^64=104,857,581,553,255,926,290,448,384 (using ttcalc), 20^20-2^128=-340,282,366,920,833,605,863,374,607,431,768,211,456
std::cout<<
std::boolalpha<<std::dec<<
"unit test of uintmaxpow(2,63) 2^63="<<uintmaxpow(2,63)<<
" should be big: "<<(overflowErr?"overflow error":"no overflow error")<<std::endl;
if (toFile) {
fout<<
std::boolalpha<<std::dec<<
"unit test of uintmaxpow(2,63) 2^63="<<uintmaxpow(2,63)<<
" should be big: "<<(overflowErr?"overflow error":"no overflow error")<<std::endl;
}
overflowErr=false;//if above failed, reset the flag
//std::cout<<""<<std::endl;
//if (toFile) {
//        fout<<""<<std::endl;
//}
for (x=minX; x<=maxX; x++) {
for (y=minY; y<=maxY; y++) {
for (z=minZ; z<=maxZ; z++) {
for (k=minK; k<=maxK; k++) {
//calculate results and print report for test per line
if (uintmaxpow(x,k) + uintmaxpow(y,k) == uintmaxpow(z,k)) {
if (!overflowErr) {//uint64pow() not set an error?
bool b=((x+y)%2==1);//odd detector
BaseType bb=x+y,cc=x+y+z,dd=x+y+k,dddd=((z+k)%1==1);
bool c=((x+y+z)%2==1);//odd detector
bool d=((x+y+z+k)%2==1);//odd detector
bool ddd=((x+y+k)%2==1);//odd detector
bool e=(x==y);//equality detector
bool f=(x==y&&y==z);//equality detector#2
bool g=(x==y&&y==z&&z==k);//equality detector#3
bool h=(x==k);//equality detector#4
bool i=(y==k);//equality detector#5
bool j=(z==k);//equality detector#6
bool kk=(0==((x+y)%2)&&(0==(z%2)));//equality detector#6
std::cout<<
"["<<
x<<"^"<<k<<
"+"<<
y<<"^"<<k<<
"="<<
z<<"^"<<k<<
"]"
",x+y="<<bb<<"odd="<<b<<
",x+y+z="<<cc<<"odd="<<c<<
",x+y+z+k="<<dd<<"odd="<<d<<
",x+y+k="<<dd<<"odd="<<ddd<<
",z+k="<<(z+k)<<"odd="<<dddd<<
",x==y:"<<e<<
",x==y==z:"<<f<<
",x==y==z==k:"<<g<<
",x==k:"<<h<<
",y==k:"<<i<<
",z==k:"<<j<<
",(0==((x+y)%2)&&(0==(z%2)))"<<kk<<
std::endl;
if (toFile) {
fout<<
"["<<
x<<"^"<<k<<
"+"<<
y<<"^"<<k<<
"="<<
z<<"^"<<k<<
"]"
",x+y="<<bb<<"odd="<<b<<
",x+y+z="<<cc<<"odd="<<c<<
",x+y+z+k="<<dd<<"odd="<<d<<
",x+y+k="<<dd<<"odd="<<ddd<<
",z+k="<<(z+k)<<"odd="<<dddd<<
",x==y:"<<e<<
",x==y==z:"<<f<<
",x==y==z==k:"<<g<<
",x==k:"<<h<<
",y==k:"<<i<<
",z==k:"<<j<<
",(0==((x+y)%2)&&(0==(z%2)))"<<kk<<
std::endl;
}
goodCount++;
//print header every 20 rows of output often so we don't lose track
//      std::cout<<""<<std::endl;
//      if (toFile) {
//              fout<<""<<std::endl;
//      }
//}
//"between good" grouped error reports
if (errCount>=1) {
std::cout<<"ERROR: "<<errCount<<" overflows between good results"<<std::endl;
//if (toFile) {
//        fout<<""<<std::endl;
//}
errCount=0;//reset grouped error count after overflowErr group report
}
} else {//overflowErr
overflowErr=false;//silently reset uint64pow() singular errors
//group errors together
errCount++;//count every error between
}//if (!overflowErr)
}//if (uint64pow(x,k) + uint64pow(y,k) == uint64pow(z,k))
}//for (k=minK; k<=maxK; k++)
}//for (z=minval; z<=maxZ; z++)
}//for (y=minval; y<=maxY; y++)
}//for (x=minval; x<=maxX; x++)
if (errCount) {
std::cout<<"ERROR: "<<errCount<<" overflows after good results"<<std::endl;
if (toFile) {
fout<<"ERROR: "<<errCount<<" overflows after good results"<<std::endl;
}
}
std::cout<<"done. "<<goodCount<<" data rows, maxBitsOverflow="<<maxBitsOverflow<<std::endl;
if (toFile) {
fout<<"done. "<<goodCount<<" data rows, maxBitsOverflow="<<maxBitsOverflow<<std::endl;
}
fout.close();
return 0;
}
```