Series Approximations for the Incomplete Elliptic Integrals of the First and Second Kind by James Pate Williams, Jr., BA, BS, MSwE, PhD

Expansion as truncated infinite power series and term-by-term integration of the integrals is illustrated in the following pictures.

Fourteen Peg Puzzle by James Pate Williams, Jr., BA, BS, MSwE, PhD

I created this project five years ago.

Technologies

C#, Visual Studio 2008, Windows Forms, Visual C#

Topics

C#, Puzzles, 14 Peg Puzzle

Platforms

Desktop

Requirements

Primary language

en-US

Updated

10/16/2015

License

MIT

View this sample online

Introduction

The fourteen peg puzzle is a form of amusement which I have seen at my local Cracker Barrel. The puzzle involves fourteen pegs in fifteen holes in a triangular configuration. The top hole is empty. The object of the puzzle is to jump pegs over one another until only one peg is left. Jumped pegs are removed from the board.

Building the Sample

This project should build as is using Visual Studio 2008.

Description

This application was translated from a Turbo Pascal program found in Data Structure Using Turbo Pascal by Thomas M. Boger. Depth-first search with backtracking is utilized to find the solution in the allowed thirteen moves. Two stacks are used to store the moves a move stack and a reverse move stack. The translation process had to take into account a relatively strange Turbo Pascal table and an array whose base index was -1. Boger creates an array for the representation of the fourteen peg puzzle that is a right triangle for internal application operations.

C#

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace FourteenPegPuzzle

{

    class PegPuzzle

    {

        private const int OverRow = 0;

        private const int OverCol = 1;

        private const int ToRow = 2;

        private const int ToCol = 3;

        private const int Addend = 0;

        private int[,] moveTable =

        {{1, 0, 2, 0}, {-1, 0, -2, 0},

            {0, 1, 0, 2}, {0, -1, 0, -2},

            {1, 1, 2, 2}, {-1, -1, -2, -2}};

        private char[,] board;

        public struct StatusRec

        {

            public int pegRow, pegCol, moveNumber;

        }

        private Stack<StatusRec> moveStack;

        private Stack<StatusRec> reverseStack;

        private bool blocked;

        private int moveCount, totalMovePush;

        private StatusRec currentMove, newMove;

        private TextBox tb;

        public PegPuzzle(TextBox tb)

        {

            this.tb = tb;

            totalMovePush = 0;

            board = new char[9, 9];

        }

        private void AdvancePeg()

        {

            currentMove.pegCol++;

            if (currentMove.pegCol > currentMove.pegRow)

            {

                currentMove.pegCol = 2;

                currentMove.pegRow++;

            }

        }

        private void AdvanceMove()

        {

            currentMove.moveNumber++;

            if (currentMove.moveNumber > 5)

            {

                currentMove.moveNumber = 0;

                AdvancePeg();

            }

        }

        private void InitializeBoard()

        {

            for (int row = 0; row < 9; row++)

                for (int col = 0; col < 9; col++)

                    board[row, col] = ‘ ‘;

            for (int row = 3; row <= 6; row++)

                for (int col = 2; col <= row; col++)

                    board[row, col] = ‘X’;

            board[2, 2] = ‘O’;

        }

        private bool LegalMove()

        {

            int overRow = moveTable[currentMove.moveNumber, OverRow] + Addend;

            int overCol = moveTable[currentMove.moveNumber, OverCol] + Addend;

            int toRow = moveTable[currentMove.moveNumber, ToRow] + Addend;

            int toCol = moveTable[currentMove.moveNumber, ToCol] + Addend;

            return board[currentMove.pegRow + overRow, currentMove.pegCol + overCol] == ‘X’ &&

                board[currentMove.pegRow + toRow, currentMove.pegCol + toCol] == ‘O’;

        }

        private void PrintBoard()

        {

            for (int row = 2; row <= 6; row++)

            {

                for (int i = 1; i <= 6 – row; i++)

                    tb.Text += ‘ ‘;

                for (int col = 2; col <= row; col++)

                    tb.Text += board[row, col] + ” “;

                tb.Text += “\r\n”;

            }

            tb.Text += “\r\n”;

        }

        public void Solve()

        {

            moveStack = new Stack<StatusRec>();

            InitializeBoard();

            blocked = false;

            moveCount = 0;

            currentMove.pegRow = 2;

            currentMove.pegCol = 2;

            currentMove.moveNumber = 0;

            while (moveCount < 13 && !blocked)

            {

                if (board[currentMove.pegRow, currentMove.pegCol] != ‘X’)

                    AdvancePeg();

                else if (!LegalMove())

                    AdvanceMove();

                else

                {

                    newMove = new StatusRec();

                    newMove.moveNumber = currentMove.moveNumber;

                    newMove.pegCol = currentMove.pegCol;

                    newMove.pegRow = currentMove.pegRow;

                    moveStack.Push(newMove);

                    moveCount++;

                    totalMovePush++;

                    board[currentMove.pegRow, currentMove.pegCol] = ‘O’;

                    int overRow = moveTable[currentMove.moveNumber, OverRow] + Addend;

                    int overCol = moveTable[currentMove.moveNumber, OverCol] + Addend;

                    int toRow = moveTable[currentMove.moveNumber, ToRow] + Addend;

                    int toCol = moveTable[currentMove.moveNumber, ToCol] + Addend;

                    board[currentMove.pegRow + overRow, currentMove.pegCol + overCol] = ‘O’;

                    board[currentMove.pegRow + toRow, currentMove.pegCol + toCol] = ‘X’;

                    currentMove.pegRow = 2;

                    currentMove.pegCol = 2;

                    currentMove.moveNumber = 0;

                }

                while (currentMove.pegRow > 6 && !blocked)

                {

                    if (moveStack.Count == 0)

                        blocked = true;

                    else

                    {

                        currentMove = moveStack.Pop();

                        board[currentMove.pegRow, currentMove.pegCol] = ‘X’;

                        int overRow = moveTable[currentMove.moveNumber, OverRow] + Addend;

                        int overCol = moveTable[currentMove.moveNumber, OverCol] + Addend;

                        int toRow = moveTable[currentMove.moveNumber, ToRow] + Addend;

                        int toCol = moveTable[currentMove.moveNumber, ToCol] + Addend;

                        board[currentMove.pegRow + overRow, currentMove.pegCol + overCol] = ‘X’;

                        board[currentMove.pegRow + toRow, currentMove.pegCol + toCol] = ‘O’;

                        moveCount–;

                        AdvanceMove();

                    }

                }

            }

            if (!blocked)

            {

                InitializeBoard();

                reverseStack = new Stack<StatusRec>();

                while (moveStack.Count != 0)

                {

                    currentMove = moveStack.Pop();

                    newMove = new StatusRec();

                    newMove.moveNumber = currentMove.moveNumber;

                    newMove.pegCol = currentMove.pegCol;

                    newMove.pegRow = currentMove.pegRow;

                    reverseStack.Push(newMove);

                }

                PrintBoard();

                while (reverseStack.Count != 0)

                {

                    currentMove = reverseStack.Pop();

                    board[currentMove.pegRow, currentMove.pegCol] = ‘O’;

                    int overRow = moveTable[currentMove.moveNumber, OverRow] + Addend;

                    int overCol = moveTable[currentMove.moveNumber, OverCol] + Addend;

                    int toRow = moveTable[currentMove.moveNumber, ToRow] + Addend;

                    int toCol = moveTable[currentMove.moveNumber, ToCol] + Addend;

                    board[currentMove.pegRow + overRow, currentMove.pegCol + overCol] = ‘O’;

                    board[currentMove.pegRow + toRow, currentMove.pegCol + toCol] = ‘X’;

                    PrintBoard();

                }

            }

        }

    }

}

A Table of Values of the Incomplete Elliptic Integrals of the First and Second Kind by James Pate Williams, Jr., BA, BS, MSwE, PhD

These incomplete elliptic integrals are one dimensional and can be readily calculated using the Gauss-Legendre one dimensional integration technique. I use a 128 points in each integral computation. The integrals have two parameters x and k. We evaluate the F(x, k), the incomplete elliptic integral of the first kind, and E(x, k), the incomplete integral of the second kind.

Volume and Surface Area of an Ellipsoid by James Pate Williams, Jr., BA, BS, MSwE, PhD

Back in the 1980s a former professor of mine in mathematics at LaGrange College posed a problem to me. He handed me a deflated football and asked me to compute the volume and surface area when it was inflated. Unfortunately, I just got around to solving the problem today, Sunday, October 11, 2020. I had some help from the Casio Corporation which has a lot of free calculators on the Internet:

https://keisan.casio.com/

I used one of their calculators to independently verify my own calculator.

Determining if a Mersenne Number is a Mersenne Prime by James Pate Williams, Jr., BA, BS, MSwE, PhD

A Mersenne number is of the form M_n = 2 ^ n – 1. For M_n to be prime, n must be prime.

M_2 = 4 – 1 = 3 prime

M_3 = 8 – 1 = 7 prime

M_4 = 16 – 1 = 15 = 3 * 5

M_5 = 32 – 1 = 31 prime

M_6 = 64 – 1 = 63 = 7 * 9

M_7 = 128 – 1 = 127 prime

M_8 = 256 – 1 = 255 = 5 * 51 = 3 * 5 * 17 = M_4 * 17

M_9 = 512 – 1 = 511 = 7 * 73

M_10 = 1024 – 1 = 1023 = 3 * 341 = 3 * 11 * 31

M_11 = 2048 – 1 = 2047 = 23 * 89

I wrote a program to determine if a number M_p = 2 ^ p – 1 with p prime is also a Mersenne prime. I used the Lucas-Lehmer test.

My First MeetUp.com Group, Ballistics by James Pate Williams, Jr., BA, BS, MSwE, PhD

MeetUp.com is a website that allows a MeetUp.com Group Coordinator to hold in person (offline) and virtual (online via Zoom.com) groups. My first group is “Ballistics” which should be more exactly “Exterior Ballistics”. Below is the MeetUp.com blurb:

This group is dedicated to the study of the United States Naval Academy textbook “Exterior Ballistics, 1935” by Ernest Edward Herrmann. The contents of this book was used extensively in World War II by the United States Navy and its battleships. The group should be able to carry out ballistic calculations both classical and including drag and other trajectory corrections. Exterior ballistics is applicable to the flights of all sorts of balls including baseballs and golf balls. It is also useful for large artillery, handgun, and rifle projectile exterior ballistics. Here is an application of the methods to the Iowa class of fast battleships and their heavy armament, the 16 inch 50 caliber rifled artillery:

The first meeting in the future will cover Classical Ballistics using an Windows Form Application or an online application I may create in the future.

Hopefully, some MeetUp.com users will find my group and will signup to be a free group attendee. As of today I am the only member of the group.

Early Electronic Nose Research by James Pate Williams, Jr., BA, BS, MSwE, PhD

Back in 1982 research into electronic olfaction (electronic sense of smell, electronic nose) began. By the mid-1990s and late 1990s viable electronic nose systems were coming into existence. That means that before the 2000s we had tackled 60% of human senses via electronic means: sight, hearing and smell. That left only the senses of feel (tactile responses) and taste were yet to be conquered. The senses of smell and taste are chemically coupled. Here is a December 1995 paper on electrochemical noses their applications: https://www.researchgate.net/publication/2747174_Electronic_Noses_And_Their_Applications This maybe of interest since covid-19 may cause temporary loss of the senses of smell and taste.

Fifty Years Ahead of the Private Sector by James Pate Williams, Jr, BA, BS, MSwE, PhD

I have heard some former or want to be National Security Officers suggest that the National Security Agency is and has been since 1952 fifty years ahead of the private sector in many active areas of research. I have clear evidence based on one 1941 document that the United States Navy was at least fifty years ahead of the war-by -wireless technology in the Ordnance Pamphlet 770 which was printed in October 1941:

https://eugeneleeslover.com/USN-GUNS-AND-RANGE-TABLES/OP-770-1.html

The approximate maximum range of the 16-inch by 50 caliber fast battleship class Iowa artillery is around 24 miles at a maximum elevation of 45 degrees. The horizon can be calculated to be at height of 60 feet above sea level to be 1.22 * (60)^(1/2) = 9.45 miles. So, the question is how can you guarantee an accurate shot at 24 miles even with the crude radar of the day? One uses a spotter aircraft to give the accurate longitude-latitude coordinates of the enemy ship. Thus, we have GPS gunnery in 1930s-1940s technology.  We are a country of warfare geniuses in the United States of North America.

I am sure there are many other examples of the U.S. getting a lot of bang for our tax dollars.

Realistic Predator-Prey Model by James Pate Williams, Jr., BA, BS, MSwE, PhD

Realistic Predator Prey Model

dN / dt = N * [r * (1 – N / K) – k * P / (N + D)] (Prey Equation)

dP/ dt = P * [s * (1 – h * P / N)] (Predator Equation)

To reduce the six-parameter model to a more manageable three parameter one introduce the following variables and parameters

u(w) = N(t) / K

v(w) = h * P(t) / K

w = r * t

a = k / (h * r)

b = s / r

d = D / K

du / dw = u – (1 – u) – a * u * v / (u + d)

dv / dw = b * v * (1 – v / u)

In my program a = alpha, d = beta, and b = gamma