Blog Entry Monday, July 15, 2024, (c) James Pate Williams, Jr. Some Values of the Riemann Zeta Function Computed with Fast and Very Slow Algorithms

The slow computations used 999,999,999 terms. I seem to recall from my first numerical analysis (Scientific Computing I) course in the Mathematics Department at the Georgia Institute of Technology with Professor Gunter Meyer in the Summer of 1982 that computing a truncated infinite series is more accurate to start with the smallest terms.

// RiemannZetaFunctionWin32Console.c (c) Saturday, July 13-15, 2024
// James Pate Williams, Jr. some computations use 999,999,998 terms

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef signed long long sll;

// https://en.wikipedia.org/wiki/Particular_values_of_the_Riemann_zeta_function#cite_note-7

long double EvenZeta(int n)
{
    sll A[12] = { 0ll,
        6ll, 90ll, 945ll, 9450ll, 93555ll, 638512875ll,
        18243225ll, 325641566250ll, 38979295480125ll,
        1531329465290625ll, 13447856940643125ll };
    sll B[12] = { 0ll, 1ll, 1ll, 1ll, 1ll, 1ll, 691ll, 2ll,
        3617ll, 43867ll, 174611ll, 155366ll };
    long double pi = 4.0 * atan(1.0);

    return (long double)B[n / 2] * powl(pi, n) / (long double)A[n / 2];
}

long double Zeta(long s, long *terms)
{
    int n = 0;
    long double sum = 0.0;

    *terms = 0;

    for (n = 1000000000; n >= 2; n--)
    {
        sum += 1.0 / powl(n, s);
        (*terms)++;
    }

    return sum + 1.0;
}

void PrintEvenZetaValue(int n)
{
    clock_t time0 = clock();
    long double ez = EvenZeta(n);
    clock_t time1 = clock();
    double runtime = ((double)time1 - time0) / CLOCKS_PER_SEC;
    printf_s("Runtime in seconds to compute Zeta(%ld) = %16.15Lf: %Lf\n",
        n, ez, runtime);
}

void PrintZetaValue(int n)
{
    clock_t time0 = clock();
    long terms = 0;
    long double zeta = Zeta(n, &terms);
    clock_t time1 = clock();
    double runtime = ((double)time1 - time0) / CLOCKS_PER_SEC;
    printf_s("Runtime in seconds to compute Zeta(%ld) = %16.15Lf terms = %ld: time = %Lf\n",
        n, zeta, terms, runtime);
}

int main()
{
    PrintEvenZetaValue(2);
    PrintEvenZetaValue(4);
    PrintEvenZetaValue(6);
    PrintEvenZetaValue(8);
    PrintZetaValue(2);
    PrintZetaValue(4);
    PrintZetaValue(6);
    PrintZetaValue(8);
    PrintZetaValue(3);
    PrintZetaValue(5);
    PrintZetaValue(7);
    PrintZetaValue(9);
    return 0;
}

Blog Entry Sunday, June 16, 2024 (c) James Pate Williams, Jr. Chapter 4 Matrices and Systems of Linear Equations from a Textbook by S. D. Conte and Carl de Boor

Blog Entry Friday, June 14, 2024 (c) James Pate Williams, Jr.

For the last week or so I have been working my way through Chapter 3 The Solution of Nonlinear Equations found in the textbook “Numerical Analysis: An Algorithmic Approach” by S. D. Conte and Carl de Boor. I also used some C source code from “A Numerical Library in C for Scientists and Engineers” by H. T. Lau, PhD. I implemented twenty examples and exercises from the previously mentioned chapter.

Blog Entry June 5-7, 2024, (c) James Pate Williams, Jr. All Applicable Rights Reserved Chapter 7 Example and Some Exercises from “Numerical Analysis: An Algorithmic Approach (c) 1980 by S. D. Conte and Carl de Boor (Numerical Differentiation and Numerical Integration)

Blog Entry June 3-4, 2024, (c) James Pate Wiliams, Jr., Solution of Tridiagonal Matrix Problems

The first solution is from the textbook, Elementary Numerical Analysis: An Algorithmic Approach (c) 1980 by S. D. Conte and Carl de Boor. I translated the FORTRAN code to vanilla C using Visual Studio 2019 Community Version. The second solution is from Boundary Value Problems Second Edition (c) 1979 by David L. Powers. It solves a simple second order linear ordinary differential equation using the finite element difference equation method.

Blog Entry for Early Morning Friday, May 31, 2024, Solutions of a Second Order Self-Adjoint Ordinary Differential Equation by Three Methods

Quantum Mechanical Angular Momentum Ladder Operators by James Pate Williams, Jr. Copyright Thursday, May 23, 2024, All Applicable Rights Reserved

Text and Exercise from “Boundary Value Problems Second Edition” by David L. Powers in Progress (c) Wednesday, April 17, 2024, James Pate Williams, Jr.