Happy 59th Anniversary of the historic moon landing by Neil Armstrong, Buzz Aldrin, and Michael Collins in Apolla 11.
Category: C Applications
Newtonian Gravity and Cosmology © Friday, July 18, 2025, by James Pate Williams, Jr. in Conjunction with the Microsoft Copilot AI
Some General Relativity Mathematics by James Pate Williams, Jr. (c) July 13, 2025
// SomeRelativityMath.cpp : Defines the entry point for the application.
// https://arxiv.org/pdf/2506.09946
#include "pch.h"
#include "framework.h"
#include "SomeRelativityMath.h"
#include <stdio.h>
#include <vector>
#define MAX_LOADSTRING 100
typedef struct tagPoint2d
{
double x, y;
} POINT2D, * PPOINT2D;
// Global Variables:
HINSTANCE hInst; // current instance
WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
char text[8192];
std::vector<POINT2D> points1, points2;
std::vector<POINT2D> points3, points4;
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DrawGraph(HWND, UINT, WPARAM, LPARAM);
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
// Initialize global strings
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_SOMERELATIVITYMATH, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SOMERELATIVITYMATH));
MSG msg;
// Main message loop:
while (GetMessage(&msg, nullptr, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEXW wcex = { 0 };
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SOMERELATIVITYMATH));
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_SOMERELATIVITYMATH);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassExW(&wcex);
}
//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
hInst = hInstance; // Store instance handle in our global variable
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
static void FindMinMax(
double& xMin, double& xMax,
double& yMin, double& yMax)
{
// uses global 2D double points structure
xMin = yMin = DBL_MAX;
xMax = yMax = DBL_MIN;
for (size_t i = 0; i < points1.size(); i++)
{
POINT2D pt = points1[i];
double x = pt.x;
double y = pt.y;
if (x < xMin)
xMin = x;
if (x > xMax)
xMax = x;
if (y < yMin)
yMin = y;
if (y > yMax)
yMax = y;
}
for (size_t i = 0; i < points2.size(); i++)
{
POINT2D pt = points2[i];
double x = pt.x;
double y = pt.y;
if (x < xMin)
xMin = x;
if (x > xMax)
xMax = x;
if (y < yMin)
yMin = y;
if (y > yMax)
yMax = y;
}
for (size_t i = 0; i < points3.size(); i++)
{
POINT2D pt = points3[i];
double x = pt.x;
double y = pt.y;
if (x < xMin)
xMin = x;
if (x > xMax)
xMax = x;
if (y < yMin)
yMin = y;
if (y > yMax)
yMax = y;
}
for (size_t i = 0; i < points4.size(); i++)
{
POINT2D pt = points4[i];
double x = pt.x;
double y = pt.y;
if (x < xMin)
xMin = x;
if (x > xMax)
xMax = x;
if (y < yMin)
yMin = y;
if (y > yMax)
yMax = y;
}
}
static void DrawFormattedText(HDC hdc, char text[], RECT rect)
{
// Draw the text with formatting options
DrawTextA(hdc, text, -1, &rect, DT_SINGLELINE | DT_NOCLIP);
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
{
double P1 = 0, P2 = 0, P3 = 0, P4 = 0;
int numberPts = 1024;
double x0 = 1, h = 0.5 / numberPts, x = x0;
points1.resize(numberPts);
points2.resize(numberPts);
points3.resize(numberPts);
points4.resize(numberPts);
for (int i = 0; i < numberPts; i++)
{
P1 = x + 1.0;
P2 = 3.0 * x * x + 4.0 * x + 2.0;
P3 = 15.0 * x * x * x + 16.0 * x * x + 6.0 * x;
P4 = 105.0 * x * x * x * x + 156.0 * x * x * x +
94.0 * x * x + 24.0 * x;
POINT2D pt = { 0 };
pt.x = x;
pt.y = log(P1);
points1[i] = pt;
pt.y = log(P2);
points2[i] = pt;
pt.y = log(P3);
points3[i] = pt;
pt.y = log(P4);
points4[i] = pt;
x += h;
}
break;
}
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
break;
case WM_PAINT:
{
double h = 0, pi = 0, plm = 0, theta = 0;
double xMax = 0, xMin = 0, yMax = 0, yMin = 0;
FindMinMax(xMin, xMax, yMin, yMax);
float xSpan = (float)(xMax - xMin);
float ySpan = (float)(yMax - yMin);
RECT rect = { };
GetClientRect(hWnd, &rect);
float width = (float)(rect.right - rect.left + 1);
float height = (float)(rect.bottom - rect.top - 32 + 1);
float sx0 = 2.0f * width / 16.0f;
float sx1 = 14.0f * width / 16.0f;
float sy0 = 2.0f * height / 16.0f;
float sy1 = 14.0f * height / 16.0f;
float deltaX = xSpan / 8.0f;
float deltaY = ySpan / 8.0f;
float xSlope = (sx1 - sx0) / xSpan;
float xInter = (float)(sx0 - xSlope * xMin);
float ySlope = (sy0 - sy1) / ySpan;
float yInter = (float)(sy0 - ySlope * yMax);
float px = 0, py = 0, sx = 0, sy = 0;
PAINTSTRUCT ps;
POINT wPt = { };
HDC hdc = BeginPaint(hWnd, &ps);
int i = 0;
float x = (float)xMin;
float y = (float)yMax;
px = x;
py = y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
MoveToEx(hdc, (int)sx, (int)sy0, &wPt);
char buffer[128] = { };
while (i <= 8)
{
sx = xSlope * x + xInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy0, &wPt);
LineTo(hdc, (int)sx, (int)sy1);
sprintf_s(buffer, "%3.2f", x);
SIZE size = { };
GetTextExtentPoint32A(
hdc,
buffer,
strlen(buffer),
&size);
RECT textRect = { };
textRect.left = (long)(sx - size.cx / 2.0f);
textRect.right = (long)(sx + size.cx / 2.0f);
textRect.top = (long)sy1;
textRect.bottom = (long)(sy1 + size.cy / 2.0f);
DrawFormattedText(hdc, buffer, textRect);
x += deltaX;
i++;
}
i = 0;
y = (float)yMin;
while (i <= 8)
{
sy = ySlope * y + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx0, (int)sy, &wPt);
LineTo(hdc, (int)sx, (int)sy);
if (i != 0)
{
sprintf_s(buffer, "%3.1f", y);
SIZE size = { };
GetTextExtentPoint32A(
hdc,
buffer,
strlen(buffer),
&size);
RECT textRect = { };
textRect.left = (long)(sx0 - size.cx - size.cx / 5.0f);
textRect.right = (long)(sx0 - size.cx / 2.0f);
textRect.top = (long)(sy - size.cy / 2.0f);
textRect.bottom = (long)(sy + size.cy / 2.0f);
DrawFormattedText(hdc, buffer, textRect);
}
y += deltaY;
i++;
}
HGDIOBJ rPenNew = NULL;
HGDIOBJ hPenOld = NULL;
rPenNew = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
hPenOld = SelectObject(hdc, rPenNew);
px = (float)points1[0].x;
py = (float)points1[0].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points1.size(); j++)
{
px = (float)points1[j].x;
py = (float)points1[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(rPenNew);
HGDIOBJ gPenNew = CreatePen(PS_SOLID, 2, RGB(0, 255, 0));
hPenOld = SelectObject(hdc, gPenNew);
px = (float)points2[0].x;
py = (float)points2[0].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points2.size(); j++)
{
px = (float)points2[j].x;
py = (float)points2[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(gPenNew);
HGDIOBJ bPenNew = CreatePen(PS_SOLID, 2, RGB(0, 0, 255));
hPenOld = SelectObject(hdc, bPenNew);
px = (float)points3[0].x;
py = (float)points3[0].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points3.size(); j++)
{
px = (float)points3[j].x;
py = (float)points3[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(bPenNew);
HGDIOBJ pPenNew = CreatePen(PS_SOLID, 2, RGB(128, 0, 128));
hPenOld = SelectObject(hdc, pPenNew);
px = (float)points4[0].x;
py = (float)points4[0].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points4.size(); j++)
{
px = (float)points4[j].x;
py = (float)points4[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(pPenNew);
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
static INT_PTR CALLBACK DrawGraph(
HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
char line[256] = { };
switch (message)
{
case WM_INITDIALOG:
GetWindowTextA(hDlg, line, 256);
strcat_s(text, 8192, " ");
strcat_s(text, 8192, line);
SetWindowTextA(hDlg, text);
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
case WM_PAINT:
double h = 0, pi = 0, plm = 0, theta = 0;
double xMax = 0, xMin = 0, yMax = 0, yMin = 0;
FindMinMax(xMin, xMax, yMin, yMax);
float xSpan = (float)(xMax - xMin);
float ySpan = (float)(yMax - yMin);
RECT rect = { };
GetClientRect(hDlg, &rect);
float width = (float)(rect.right - rect.left + 1);
float height = (float)(rect.bottom - rect.top - 32 + 1);
float sx0 = 2.0f * width / 16.0f;
float sx1 = 14.0f * width / 16.0f;
float sy0 = 2.0f * height / 16.0f;
float sy1 = 14.0f * height / 16.0f;
float deltaX = xSpan / 8.0f;
float deltaY = ySpan / 8.0f;
float xSlope = (sx1 - sx0) / xSpan;
float xInter = (float)(sx0 - xSlope * xMin);
float ySlope = (sy0 - sy1) / ySpan;
float yInter = (float)(sy0 - ySlope * yMax);
float px = 0, py = 0, sx = 0, sy = 0;
PAINTSTRUCT ps;
POINT wPt = { };
HDC hdc = BeginPaint(hDlg, &ps);
int i = 0;
float x = (float)xMin;
float y = (float)yMax;
px = x;
py = y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
MoveToEx(hdc, (int)sx, (int)sy0, &wPt);
char buffer[128] = { };
while (i <= 8)
{
sx = xSlope * x + xInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy0, &wPt);
LineTo(hdc, (int)sx, (int)sy1);
sprintf_s(buffer, "%3.0f", x);
SIZE size = { };
GetTextExtentPoint32A(
hdc,
buffer,
strlen(buffer),
&size);
RECT textRect = { };
textRect.left = (long)(sx - size.cx / 2.0f);
textRect.right = (long)(sx + size.cx / 2.0f);
textRect.top = (long)sy1;
textRect.bottom = (long)(sy1 + size.cy / 2.0f);
DrawFormattedText(hdc, buffer, textRect);
x += deltaX;
i++;
}
i = 0;
y = (float)yMin;
while (i <= 8)
{
sy = ySlope * y + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx0, (int)sy, &wPt);
LineTo(hdc, (int)sx, (int)sy);
if (i != 0)
{
sprintf_s(buffer, "%3.0f", y);
SIZE size = { };
GetTextExtentPoint32A(
hdc,
buffer,
strlen(buffer),
&size);
RECT textRect = { };
textRect.left = (long)(sx0 - size.cx - size.cx / 5.0f);
textRect.right = (long)(sx0 - size.cx / 2.0f);
textRect.top = (long)(sy - size.cy / 2.0f);
textRect.bottom = (long)(sy + size.cy / 2.0f);
DrawFormattedText(hdc, buffer, textRect);
}
y += deltaY;
i++;
}
HGDIOBJ rPenNew = NULL;
HGDIOBJ hPenOld = NULL;
rPenNew = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
hPenOld = SelectObject(hdc, rPenNew);
px = (float)points1[1].x;
py = (float)points1[1].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points1.size(); j++)
{
px = (float)points1[j].x;
py = (float)points1[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(rPenNew);
px = (float)points2[1].x;
py = (float)points2[1].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
HGDIOBJ gPenNew = CreatePen(PS_SOLID, 2, RGB(0, 255, 0));
hPenOld = SelectObject(hdc, gPenNew);
px = (float)points2[1].x;
py = (float)points2[1].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points2.size(); j++)
{
px = (float)points2[j].x;
py = (float)points2[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(gPenNew);
px = (float)points3[1].x;
py = (float)points3[1].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
HGDIOBJ bPenNew = CreatePen(PS_SOLID, 2, RGB(0, 0, 255));
hPenOld = SelectObject(hdc, bPenNew);
px = (float)points3[1].x;
py = (float)points3[1].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points3.size(); j++)
{
px = (float)points3[j].x;
py = (float)points3[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(bPenNew);
px = (float)points4[1].x;
py = (float)points4[1].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
HGDIOBJ tPenNew = CreatePen(PS_SOLID, 2, RGB(128, 0, 128));
hPenOld = SelectObject(hdc, tPenNew);
px = (float)points4[1].x;
py = (float)points4[1].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
wPt.x = wPt.y = 0;
MoveToEx(hdc, (int)sx, (int)sy, &wPt);
for (size_t j = 1; j < points4.size(); j++)
{
px = (float)points4[j].x;
py = (float)points4[j].y;
sx = xSlope * px + xInter;
sy = ySlope * py + yInter;
LineTo(hdc, (int)sx, (int)sy);
}
SelectObject(hdc, hPenOld);
DeleteObject(tPenNew);
EndPaint(hDlg, &ps);
return (INT_PTR)FALSE;
break;
}
return (INT_PTR)FALSE;
}
Historical Attendance Data for the First United Methodist Church (FUMC) of LaGrange, Georgia for the Year 2006 and Modeling the Data Using Various Polynomials and Least Squares Fitting by James Pate Williams, Jr., BA, BS, Master of Software Engineering and Doctor of Philosophy in Computer Science
Historical Attendance Data for the Four Services Offered by the First United Methodist Church of LaGrange, Georgia, Compiled and Analyzed by James Pate Williams, Jr.
Blog Entry (c) Thursday, June 19, 2025, Factorizations of Some Composite Integers Using Two Different Computer Languages and Methods
Factorizations of the Seventh Fermat Number
and Other Composite Integers Using the
Pollard-Shor-Williams C# App and the LIP
Lenstra Elliptic Curve Method
It took 20.1 hours for J. M. Pollard to
factor the Seventh Fermat Number in
December 1988. He was using an 8-bit
Philips P2012 personal computer with
64k RAM and two 640k floppy drives.
His seven programs were written in the
Pascal computer language. The current
author was using a 64-bit Core i5 Dell
Latitude 3410 notebook computer with
8 GB RAM and a 235 GB solid state
hard drive. The computer language was
Windows 32 vanilla C in the Release x64
Configuration. The operating system was
Windows 11 Pro with the Visual Studio
2022 Community Version Integrated
Development Environment and C#.
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 1
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:20:31.359
Function Evaluations = 661379586
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 2
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:12:31.146
Function Evaluations = 283327140
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 3
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:21:53.637
Function Evaluations = 371472150
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 4
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:15:25.712
Function Evaluations = 197866620
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 5
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:03:06.030
Function Evaluations = 19501012
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 6
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:12:25.076
Function Evaluations = 198404541
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 7
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:20:59.172
Function Evaluations = 168943987
2^128+1
340282366920938463463374607431768211457 39
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 8
59649589127497217 p 17
5704689200685129054721 p 22
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:04:58.588
Function Evaluations = 13754504
Using Lenstra's Elliptic Curve Method
enter the number to be factored below:
2^128+1
340282366920938463463374607431768211457
number has 39 digits
== Menu ==
1 Cohen's Brent-Pollard Method
2 Cohen's Trial Division
3 Lenstra's Elliptic Curve Method
4 Pollard p-1 Method First Stage
5 Pollard p-1 Both Stages
6 Pollard-Shor-Williams Method
7 Exit Application
Enter an option '1' to '7':
3
factorization is complete
Runtime in seconds:
1.00000 sec.
original number has 39-decimal digits
'c' means composite and 'p' means prime
59649589127497217 17-decimal digits p
5704689200685129054721 22-decimal digits p
enter the number to be factored below:
Miscellaneous numbers using the C# app:
2^32+1
4294967297 10
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 1
641 p 3
6700417 p 7
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:00.034
Function Evaluations = 57
2^41-1
2199023255551 13
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 1
13367 p 5
164511353 p 9
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:00.003
Function Evaluations = 1128
2^67-1
147573952589676412927 21
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 1
193707721 p 9
761838257287 p 12
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:00.065
Function Evaluations = 30519
2^144-3
22300745198530623141535718272648361505980413 44
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 1
492729991333 p 12
45259565260477899162010980272761 p 32
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:04.804
Function Evaluations = 2458746
2^32+1
4294967297 10
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 5
641 p 3
6700417 p 7
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:00.001
Function Evaluations = 81
2^41-1
2199023255551 13
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 5
13367 p 5
164511353 p 9
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:00.002
Function Evaluations = 174
2^67-1
147573952589676412927 21
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 5
193707721 p 9
761838257287 p 12
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:00.050
Function Evaluations = 35949
2^144-3
22300745198530623141535718272648361505980413 44
Pseudo-Random Number Generator Seed = 1
Number of Tasks = 5
492729991333 p 12
45259565260477899162010980272761 p 32
Total Elapsed Runtime Hrs:Min:Sec.MS = 00:00:01.613
Function Evaluations = 632928
Now Lenstra's ECM:
enter the number to be factored below:
2^32+1
4294967297
number has 10 digits
== Menu ==
1 Cohen's Brent-Pollard Method
2 Cohen's Trial Division
3 Lenstra's Elliptic Curve Method
4 Pollard p-1 Method First Stage
5 Pollard p-1 Both Stages
6 Pollard-Shor-Williams Method
7 Exit Application
Enter an option '1' to '7':
3
factorization is complete
Runtime in seconds:
0.00000 sec.
original number has 10-decimal digits
'c' means composite and 'p' means prime
641 3-decimal digits p
6700417 7-decimal digits p
enter the number to be factored below:
2^41-1
2199023255551
number has 13 digits
== Menu ==
1 Cohen's Brent-Pollard Method
2 Cohen's Trial Division
3 Lenstra's Elliptic Curve Method
4 Pollard p-1 Method First Stage
5 Pollard p-1 Both Stages
6 Pollard-Shor-Williams Method
7 Exit Application
Enter an option '1' to '7':
3
factorization is complete
Runtime in seconds:
0.00000 sec.
original number has 13-decimal digits
'c' means composite and 'p' means prime
13367 5-decimal digits p
164511353 9-decimal digits p
enter the number to be factored below:
2^67-1
147573952589676412927
number has 21 digits
== Menu ==
1 Cohen's Brent-Pollard Method
2 Cohen's Trial Division
3 Lenstra's Elliptic Curve Method
4 Pollard p-1 Method First Stage
5 Pollard p-1 Both Stages
6 Pollard-Shor-Williams Method
7 Exit Application
Enter an option '1' to '7':
3
factorization is complete
Runtime in seconds:
0.00000 sec.
original number has 21-decimal digits
'c' means composite and 'p' means prime
193707721 9-decimal digits p
761838257287 12-decimal digits p
enter the number to be factored below:
2^144-3
22300745198530623141535718272648361505980413
number has 44 digits
== Menu ==
1 Cohen's Brent-Pollard Method
2 Cohen's Trial Division
3 Lenstra's Elliptic Curve Method
4 Pollard p-1 Method First Stage
5 Pollard p-1 Both Stages
6 Pollard-Shor-Williams Method
7 Exit Application
Enter an option '1' to '7':
3
factorization is complete
Runtime in seconds:
0.00000 sec.
original number has 44-decimal digits
'c' means composite and 'p' means prime
492729991333 12-decimal digits p
45259565260477899162010980272761 32-decimal digits p
enter the number to be factored below:
For the last number 2^144-3 it took J. M. Pollard's
factoring with cubic integers 47 hours in 1988.
Blog Entry © Sunday, June 8, 2025, Chemical Reaction Kinetics by James Pate Williams, Jr.
Blog Entry © Thursday, June 5, 2025, by James Pate Williams, Jr., Analytic, Numeric, and Siacci’s Method for Solving Ballistic Trajectory Problems (Point-Mass Projectile Motion)
Blog Entry © Wednesday, June 4, 2025, Differential Cryptanalysis of DES by James Pate Williams, Jr.
Below are outputs from three different apps perform differential cryptanalysis on three, four, and six round DES algorithms. Three round is first etc.
E = 007e0e80 680c0000
E* = bf02ac05 40520000
C' = 965d5b67
E = a0bff415 02f60000
E* = 8a6a5ebf 28aa0000
C' = 9c9c1f56
E = ef15068f 695f0000
E* = 05e9a2bf 56040000
C' = d575db2b
1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0
0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 1 0 3 0 0 1 0 0 1 0 0 0 0
0 1 0 0 0 2 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0
0 0 1 1 0 0 0 0 1 0 1 0 2 0 0 0
0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0
0 0 0 3 0 0 0 0 0 0 0 0 0 0 1 1
0 2 0 0 0 0 0 0 0 0 0 0 1 1 0 0
0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0
3 1 0 0 0 0 0 0 0 0 2 2 0 0 0 0
0 0 0 0 1 1 0 0 0 0 0 0 1 0 1 1
1 1 1 0 1 0 0 0 0 1 1 1 0 0 1 0
0 0 0 0 1 1 0 0 0 0 0 0 0 0 2 1
0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0
0 0 0 0 2 0 0 0 3 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 2 0 0 0 0 0 0 1 0 0 0 0 2 0
1 0 0 1 1 0 0 3 0 0 0 0 1 0 0 1
0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0
1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0
0 0 2 1 0 1 0 3 0 0 0 1 1 0 0 0
0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1
0 0 2 0 0 0 2 0 0 0 0 1 2 1 1 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 1 0 0 1 0 1
0 3 0 0 0 0 1 0 0 0 0 0 0 0 0 0
47 05 19 00 24 07 07 49
J = bc54c060 71f10000
key = 0001101P0110001P01?01?0P1?00100P0101001P0000??0P111?11?P?100011P
88
Unknown bit count = 8
key = 0001101001100010010011001000100101010010000011011110110001000110
key = 1a624c89 520dec46
E = f069a40a a8a70000
E* = c0e9f28f 810f0000
C' = fa719d15
E = dabefbef 01a70000
E* = c03fa95f 29570000
C' = ea5605a1
E = ca7d095a 815f0000
E* = d57d094a 800f0000
C' = 0b00c0cb
E = 7fbf56aa 43050000
E* = 65945eba 55550000
C' = 0923cbd6
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0
2 0 2 1 1 0 0 0 2 1 0 0 1 0 0 0
1 0 0 1 1 0 0 2 0 1 0 1 0 0 0 2
4 1 1 0 2 0 1 0 1 1 1 0 1 0 1 0
1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0
1 1 2 1 1 1 1 2 3 2 1 2 1 1 2 1
1 1 2 1 1 1 1 2 1 2 2 1 1 2 1 2
2 3 1 1 4 2 2 2 1 1 1 1 2 2 1 1
1 2 1 1 1 2 1 1 1 1 1 1 1 1 2 2
1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1
1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1
1 1 1 2 2 4 1 1 1 1 2 1 2 2 1 2
1 1 1 2 1 2 1 2 1 2 1 1 2 1 1 1
0 1 1 0 0 0 1 0 0 1 0 0 1 1 1 0
0 1 0 1 0 0 0 1 2 0 1 0 3 0 1 0
4 0 1 1 2 1 1 0 0 0 1 1 1 0 0 2
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 2 1 1 1 1 1 1 1 1 2 4 1 2
1 1 1 1 1 1 1 1 1 1 2 2 1 2 1 3
1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1
1 2 1 2 3 1 3 1 1 1 1 1 1 1 1 1
1 0 2 2 0 0 0 1 0 2 1 0 2 0 0 0
1 1 0 0 0 1 0 0 0 1 4 1 0 0 0 1
1 1 1 0 0 2 0 1 0 0 1 0 1 0 0 0
0 0 1 1 0 0 0 0 1 1 0 0 1 0 0 0
0 0 0 0 0 0 0 0 1 0 4 2 1 1 1 0
0 0 0 0 0 0 0 1 0 0 3 2 0 1 0 1
1 0 1 1 1 0 1 0 0 0 2 0 0 1 0 0
0 0 0 1 0 0 0 1 0 0 2 0 0 1 0 1
00 32 36 37 32 13 26 10
J = 02092580 d68a0000
key = 10?10?0P???1101P0011000P0000??0P00??01?P??00100P?101000P11?0101P
Unknown bit Count = 14
7774
key = 1001010011111011001100010000000100100110110010001101000011001011
key = 94fb3101 26c8d0cb
Plaintext-Ciphertext Pairs:
0 748502cd 38451097 03c70306 d8a09f10
0 38747564 38451097 78560a09 60e6d4cb
1 48691102 6acdff31 45fa285b e5adc730
1 375bd31f 6acdff31 134f7915 ac253457
2 357418da 013fec86 d8a31b2f 28bbc5cf
2 12549847 013fec86 0f317ac2 b23cb944
Possible J Values:
J # J Cnt J-Value(s):
0 1 47
1 1 5
2 1 19
3 1 0
4 1 24
5 1 7
6 1 7
7 1 49
key = 0001101001100010010011001000100101010010000011011110110001000110
tst = 0001101001100010010011001000100101010010000011011110110001000110
key = 1a624c89 520dec46
tst = 1a624c89 520dec46
J # J-Value True J-Value:
0 47 47
1 5 5
2 19 19
3 0 0
4 24 24
5 7 7
6 7 7
7 49 49
Tested Keys # = 1073
Runtime (s) = 0
Runtime per test (s) = 0.000028
Runtime max estimated (s) = 0.029784
Blog Entry (c) Tuesday, June 3, 2025, Sorting Algorithms by James Pate Williams, Jr.
First, we make sure the sorts actually work as expected and then we do some timing tests.
^^ Integer Data ^^
** Options Menu **
1 Single Sorting Tests
2 Statistical Tests
3 Create log file and log events
4 Exit
Option number: 1
-- Single Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number: 1
Insertion Sort
PRNG Seed 1
Number of Samples 20
Maximum Sample Value 20
11 -17
-16 -16
9 -14
-17 -12
-14 -7
17 0
10 0
0 3
7 6
3 7
8 7
0 8
-7 9
11 10
-12 11
13 11
7 12
12 13
16 16
6 17
-- Single Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number: 2
std::qsort
PRNG Seed 1
Number of Samples 20
Maximum Sample Value 20
11 -17
-16 -16
9 -14
-17 -12
-14 -7
17 0
10 0
0 3
7 6
3 7
8 7
0 8
-7 9
11 10
-12 11
13 11
7 12
12 13
16 16
6 17
-- Single Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number: 3
Singleton's FORTRAN Sort
PRNG Seed 1
Number of Samples 20
Maximum Sample Value 20
11 -17
-16 -16
9 -14
-17 -12
-14 -7
17 0
10 0
0 3
7 6
3 7
8 7
0 8
-7 9
11 10
-12 11
13 11
7 12
12 13
16 16
6 17
-- Single Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number:
^^ Integer Data ^^
** Options Menu **
1 Single Sorting Tests
2 Statistical Tests
3 Create log file and log events
4 Exit
Option number: 2
-- Statistical Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number: 1
Insertion Sort
PRNG Seed 1
Number of Samples 1000
Maximum Sample Value 1000
Number of Experiments 100
Runtimes in microseconds
Minimum runtime 524
Maximum runtime 1751
Mean runtime 802
Median runtime 668
-- Statistical Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number: 2
std::qsort
PRNG Seed 1
Number of Samples 1000
Maximum Sample Value 1000
Number of Experiments 100
Runtimes in microseconds
Minimum runtime 115
Maximum runtime 1751
Mean runtime 481
Median runtime 391
-- Statistical Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number: 3
Singleton's FORTRAN Sort
PRNG Seed 1
Number of Samples 1000
Maximum Sample Value 1000
Number of Experiments 100
Runtimes in microseconds
Minimum runtime 93
Maximum runtime 1751
Mean runtime 363
Median runtime 174
-- Statistical Sorting Tests --
1 Insertion Sort
2 std::qsort
3 Singleton's FORTRAN Sort
4 Exit Submenu
5 Exit Program
Sort option number:
; Copilot and James Pate Williams, Jr.
; 2/8/2025 - 2/9/2025
; We use the eax register for array indices
; The array base in register ecx
; The register ebx is general purpose;
;
;class SortingCPP {
;public:
; static void InsertionSort(std::vector<T>& a)
; {
; for (size_t j = 1; j < a.size(); j++)
; {
; T key = a[j];
; int i = j - 1;
;
; while (i >= 0 && a[i] > key)
; {
; a[i + 1] = a[i];
; i--;
; }
;
; a[i + 1] = key;
; }
; };
.MODEL FLAT, C
.STACK 4096
.DATA
; Allocate space for uninitialized variables
i DWORD ?
j DWORD ?
key DWORD ?
n DWORD ?
t DwORD ?
.CODE
InsertionSortASM PROC
; Parameters:
; array = [esp + 8]
; n = [esp + 12]
push ebp
mov ebp, esp
sub esp, 16 ; Allocate space for local variables
mov ecx, [ebp + 8] ; base of array
mov eax, [ebp + 12] ; n number of array elements
mov [n], eax ; store n
; Initialize variables
mov dword ptr [i], 0 ; i = 0
mov dword ptr [j], 1 ; j = 1
for_loop:
mov eax, [j] ; load j into register
mov ebx, [n] ; load n
cmp eax, ebx ; compare j to n
je Exit ; we are done
mov ebx, [ecx + eax * 4] ; ebx = a[j]
mov [key], ebx ; key = a[j]
dec eax ; j = j - 1
mov [i], eax; ; i = j - 1
inc eax ; increment
inc eax ; j = j + 1
mov [j], eax ; store j
while_loop:
mov eax, [i] ; load i into register
cmp eax, -1 ; is i == -1 ?
jz end_while ; end the while loop
mov ebx, [ecx + eax * 4] ; load a[i]
mov eax, [key] ; load key into register
cmp ebx, eax ; compare a[i] to key
jle end_while ; end the while loop
mov eax, [i] ; load i
mov ebx, [ecx + eax * 4] ; load a[i]
inc eax ; eax = i + 1
mov edx, [ecx + eax * 4] ; load a[i + 1]
;mov [t], ebx ; t = a[i]
mov edx, ebx ; edx = a[i]
mov eax, [i] ; load i again
inc eax ; i + 1
mov [ecx + eax * 4], edx ; a[i + 1] = a[i]
dec eax ; i--
dec eax ; i--
mov [i], eax ; store updated i
jmp while_loop ; continue while
end_while:
mov eax, [i] ; load i
inc eax ; eax = i + 1
mov ebx, [key] ; ebx = key
mov [ecx + eax * 4], ebx ; a[i + 1] = key
jmp for_loop ; continue for loop
Exit:
mov esp, ebp
pop ebp
ret
InsertionSortASM ENDP
END