NOAA Contiguous United States of America Temperature Anomaly by James Pate Williams Jr BA, BS, MSwE, PhD

I designed and implemented a C# computer language application to model the temperature anomaly data found on the NOAA website:

https://www.ncdc.noaa.gov

I used the latest recommended data for time period 1895 to 2017. The empirical modeling paradigm I used was simple linear regression. My model goes out to the year 2300. The key formulas used by the model are:

Simple Linear Regression Equations

See the website:

https://en.wikipedia.org/wiki/Simple_linear_regression

Below are some plots of the temperature anomaly.

Temperature Anomaly Actual Anomaly in Red Theoretical in Blue
Temperature Anomaly Actual Anomaly in Red Theoretical in Blue
Temperature Anomaly Actual Anomaly in Red Theoretical in Blue
Temperature Anomaly Actual Anomaly in Red Theoretical in Blue
Temperature Anomaly Actual Anomaly in Red Theoretical in Blue
Temperature Anomaly Actual Anomaly in Red Theoretical in Blue
Temperature Anomaly Actual Anomaly in Red Theoretical in Blue
C# Application Main Form
Simple Linear Regression Parameters
Table Function Form with Experimental and Theoretical Anomalies

The Laplace Equation in Various Orthogonal Rectilinear Coordinate Systems James Pate Williams, Jr. BA, BS, MSwE, PhD

Solve the Laplace equation in the following orthogonal rectilinear coordinate systems:

  1. Cartesian coordinates
  2. Cylindrical coordinates
  3. Spherical polar coordinates
  4. Parabolic cylindrical coordinates

Solution PDF:

Laplace Equation

Four Techniques for One Dimensional Riemann Definite Integration by James Pate Williams, Jr. BA, BS, MSwE, PhD

The four methods considered in this study are as follows:

  1. Trapezoidal Rule
  2. Simpson’s Rule
  3. Gauss-Legendre Quadrature
  4. Monte Carlo Method

The trapezoidal rule requires (n  + 2) function evaluations, n real number increments, and six additional real number arithmetic operations. Simpson’s rule involves (n + 2) function evaluations, n real number increments, and ten additional real number arithmetic operations. Gauss-Legendre quadrature uses n function evaluations, 3 * n real number arithmetic operations, 2 * n index operations, and five additional arithmetic operations. Finally, the Monte Carlo Method requires n function evaluations, n random number generations, 2 * n + 3 additional real number arithmetic operations. The Gauss-Legendre quadrature also involves some complicated orthogonal polynomial operations to determine the abscissas and weights. Below are some results from our test C# application.

ResultsForm 10_25_2018 5_20_34 PMResultsForm 10_25_2018 5_21_14 PMResultsForm 10_25_2018 5_21_28 PMResultsForm 10_25_2018 5_22_26 PMResultsForm 10_25_2018 5_22_47 PMResultsForm 10_25_2018 5_23_05 PMResultsForm 10_25_2018 5_23_52 PMResultsForm 10_25_2018 5_24_19 PMResultsForm 10_25_2018 5_24_39 PM

We conclude from the preceding dearth of tests that for given n the order of accuracy is generally Gauss-Legendre, Simpson’s, Trapezoidal, and finally Monte Carlo.

ASP .NET AJAX Timer Demonstration by James Pate Williams, Jr. BA, BS, MSwE, PhD

Sometimes in a web application you want to time the user’s input. Suppose you have a one textbox web form and you want to set an inactivity timer of 1200 seconds which is equal to 20 minutes. Every time the user adds or modifies the textbox the timer is reset to 0. The following pictures tell the story of my implementation of such a server-side timer in ASP .NET using an AJAX timer object.

Microsoft Edge 10_13_2018 4_29_27 PMMicrosoft Edge 10_13_2018 4_29_48 PMMicrosoft Edge 10_13_2018 4_30_22 PMMicrosoft Edge 10_13_2018 4_31_27 PMMicrosoft Edge 10_13_2018 4_31_44 PMMicrosoft Edge 10_13_2018 4_51_20 PMMicrosoft Edge 10_13_2018 4_52_03 PMMicrosoft Edge 10_13_2018 4_52_25 PMMicrosoft Edge 10_13_2018 4_57_43 PM

AJAX Timer Demonstration Source Code

Calculating a Few Digits of the Transcendental Number Pi by Throwing Darts by James Pate Williams, BA, BS, MSwE, PhD

Suppose you have a unit square with a circle of unit diameter inscribed . You can compute a few digits of the transcendental number, pi, 3.1415926535897932384626433832795…, by using the algorithm described as follows. Let n be the number of darts to throw and h be the number of darts that land within the inscribed circle.

h = 0

for i = 1 to n do

Choose two random numbers x and y such that x and y are contained in the interval 0 to 1 inclusive that is x and y contained in [0, 1]

Let u = x – 1 / 2 and v = y – 1 / 2

if u * u + v * v <= 0.25 = 1 / 4 then h = h + 1

next i

pi = 4 * h / n

Below are the results of a C# Microsoft Visual Studio simulation project. In the first case we throw 100,000 darts and get two significant digits of pi and then we throw a 1,000,000 darts and five significant digits of pi are computed. Of course, in a previous entry by this author we can calculate hundreds or thousands of digits of pi in relatively little time:

https://jamespatewilliamsjr.wordpress.com/2018/07/01/the-bailey-borwein-plouffe-formula-for-calculating-the-first-n-digits-of-pi/

MainForm 10_16_2018 3_04_04 AMMainForm 10_16_2018 3_05_45 AMMainForm 10_16_2018 3_09_36 AMMainForm 10_16_2018 3_09_54 AM

MonteCarloPi Source Code

Root Finding Algorithms by James Pate Williams, BA, BS, MSwE, PhD

We designed and implemented a C# application that uses the following root finding algorithms:

  1. Bisection Method
  2. Brent’s Method
  3. Newton’s Method
  4. Regula Falsi

https://en.wikipedia.org/wiki/Bisection_method

https://en.wikipedia.org/wiki/Brent%27s_method

https://en.wikipedia.org/wiki/Newton%27s_method

https://en.wikipedia.org/wiki/False_position_method

rfa f 1

rfa f 2

bs 0bs 1br 1nm 1rf 1bs 2br 2nm 2rf 2bs 3br 3nm 3rf 3nm 0rf 0

The source code files are displayed below as Word files:

BisectionMethod – Copy

BrentsMethod – Copy.cs

MainForm – Copy.cs

NewtonsMethod – Copy.cs

RegulaFalsi – Copy.cs

Roots of Small Degree Polynomials with Real Coefficients by James Pate Williams, BA, BS, MSwE, PhD

We designed and implemented quadratic formula, cubic formula, and quartic formula solvers using the formulas in the Wikipedia articles:

https://en.wikipedia.org/wiki/Quadratic_formula

https://en.wikipedia.org/wiki/Cubic_function

https://en.wikipedia.org/wiki/Quartic_function

We tested our C# implementation against:

https://keisan.casio.com/exec/system/1181809415

http://www.wolframalpha.com/widgets/view.jsp?id=3f4366aeb9c157cf9a30c90693eafc55

https://keisan.casio.com/exec/system/1181809416

Here are screenshots of the C# application:

sd 0

sd 2 0

sd 2 1

sd 2 2

sd 3 1

sd 3 0

sd 4 0

sd 4 1

C# source code files for the application:

CubicEquation – Copy.cs

IOForm – Copy.cs

MainForm – Copy.cs

QuadraticEquation – Copy.cs

QuarticEquation – Copy.cs

A Simple and Utilitarian C# Matrix Class by James Pate Williams, BA, BS, MSwE, PhD

We designed and implemented a simple and utilitarian C# matrix class for double precision numbers. The class has the binary matrix operators +, -, *, / which are addition, subtraction, multiplication, and division of two matrices. We also include an operator for multiplication of matrix by a scalar and an operator for dividing a matrix by a scalar. We have included functions to compute the p-norm, p, q-norm, and max norm of a matrix. We also can calculate using truncated infinite series the exponential, cosine, and sine function of a matrix. The exponential and trigonometric functions use a powering function that raises a matrix to a non-negative integral power.

Below is a screenshot of the test Windows Forms application. We execute the four binary matrix operators in the order +, -, *, / e.g. A+B, A-B, A*B, A/B. In order to divide by B, the matrix B must be square and non-singular, that is square and invertible.

Matrix Example Application Screenshot

The B matrix has the form of the matrix in the online discussion:

http://www.purplemath.com/modules/mtrxinvr2.htm

We create a project named MatrixExample. In this project we add a Matrix class whose code is given below:

Matrix

I leave it as an exercise for the reader to test the various norms and other functions.

 

The Bailey-Borwein-Plouffe Formula for Calculating the First n Digits of Pi

The Bailey-Borwein-Plouffe formula for determining the digits of pi was discovered in 1995. This formula has been utilized to find the exact digits of pi to many decimal places.

I recently re-implemented my legacy C and FreeLIP program that utilized the BBP formula. The new C# application uses a homegrown big unsigned decimal number package that includes methods for +, -, *, / operators and an exponentiation (power) function. I used short integers (16-bit signed integers) to represent the individual digits of the number in any base whose square can be expressed as a positive short integer. That includes the decimal base 10 and hexadecimal base 16. For this application the base was chosen to be 10. Also, included was a n-digits of pi function that used the C# language’s built-in BigInteger data type.  Below are some screen shots of the program in action.

BBP Formula BI 1000

BBP Formula BD 1000

As you can easily see the BigInteger implementation is an order of magnitude faster that the BigDecimal version (actually around 27+ times faster).

Last, we include a link to a PDF containing data comparing calculations performed on a Intel based desktop versus an AMD based laptop.

Benchmark Calculations Using the Application BigIntegerPi

Microsoft Outlook Add-In by James Pate Williams, Jr. BA, BS, MSwE, PhD

After successfully downloading and installing a free one-month trial evaluation version of Microsoft’s Visual Studio 2017 Professional Graphical User Interface Integrated Development Environment, I decided to try my hand at creating an Office VSTO Add-In. I chose the computer language C# and the Office application Outlook. Among other functions Outlook is a personal computer’s email client for IMAP or POP3. The problem that the add-in solves is a preliminary evaluation of the meaning of an email’s body. The add-in counts the frequency of occurrence of the following (assuming English language):

  1. Characters
  2. Lines Separated by CR/LF
  3. Words
  4. Danger Words – words that indicate danger to the author and/or other people, places, or things
  5. Cuss or Curse Words
  6. Hate and Objectionable Words
  7. Lower Case Characters
  8. Upper Case Characters
  9. Numeric Characters
  10. Consonant Count Including ‘y’
  11. Vowel Count Excluding the Sometimes ‘y’
  12. Punctuation Count {‘.’, ‘,’, ‘;’, ‘:’, ‘?’, ‘!’}

Once an email is opened and in an active inspector the OutlookAddIn1’s Outlook ribbon is displayed with 12 edit boxes that contain the counts enumerated in the preceding numbered list. Below is an email that illustrates night of the frequency tabulations.

Outlook AddIn Test Blog 1

The next email contains danger, cuss, and hate words.

Outlook AddIn Test Blog 2

https://social.technet.microsoft.com/Profile/james%20pate%20williams%20jr

https://www.facebook.com/pg/JamesPateWilliamsJrConsultant/posts/

https://www.linkedin.com/in/james-williams-1a5b1370/