Blog Entry © Tuesday, April 14, 2026, by James Pate Williams, Jr. Exercises and Supplementary Problems from Introduction to Vector Analysis Fourth Edition © 1979 by Harry F. Davis and Arthur David Snider Selected Exercises from Chapter 1 Page 48

// VectorAnalysis.cpp © Tuesday, April 14, 2026
// by James Pate Williams, Jr.
// Reference: Introduction to Vector Analysis Fourth Edition
// © 1979 by Harry F. Davis and Arthur David Snider 

#include <iostream>
#include <vector>

static double InnerProduct(
	std::vector<double> A,
	std::vector<double> B,
	int n)
{
	double sum = 0.0;

	for (int i = 0; i < n; i++)
		sum += A[i] * B[i];

	return sum;
}

static void VectorProduct(
	std::vector<double> A,
	std::vector<double> B,
	std::vector<double>&C)
{
	C.resize(3);
	C[0] = A[1] * B[2] - A[2] * B[1];
	C[1] = A[0] * B[2] - A[2] * B[0];
	C[2] = A[0] * B[1] - A[1] * B[0];
}

static double TripleProduct(
	std::vector<double> A,
	std::vector<double> B,
	std::vector<double> C)
{
	double sum0 = 0.0, sum1 = 0.0;

	sum0 += A[0] * B[1] * C[2] + A[1] * B[2] * C[0] + A[2] * B[0] * C[1];
	sum1 += A[1] * B[0] * C[2] + A[0] * B[2] * C[1] + A[2] * B[1] * C[0];
	return sum0 - sum1;
}

static void Exercises_Section_1_13_1_Triple_Products()
{
	// triple products (a)
	std::vector<double> A1 = { 2, 0, 0 };
	std::vector<double> B1 = { 0, 3, 0 };
	std::vector<double> C1 = { 0, 0, 5 };
	double tp_1 = TripleProduct(A1, B1, C1);
	std::cout << "Exercise 1 (a)" << '\t';
	std::cout << tp_1 << std::endl;
	// triple products (b)
	std::vector<double> A2 = { 1, 1, 1 };
	std::vector<double> B2 = { 3, 1, 0 };
	std::vector<double> C2 = { 0, -1, 5 };
	std::cout << "Exercise 1 (b)" << '\t';
	double tp_2 = TripleProduct(A2, B2, C2);
	std::cout << tp_2 << std::endl;
	// triple products (c)
	std::vector<double> A3 = { 2, -1, 1 };
	std::vector<double> B3 = { 1, 1, 1 };
	std::vector<double> C3 = { 2, 0, 3 };
	double tp_3 = TripleProduct(A3, B3, C3);
	std::cout << "Exercise 1 (c)" << '\t';
	std::cout << tp_3 << std::endl;
	// triple products (d)
	std::vector<double> A4 = { 0, 0, 1 };
	std::vector<double> B4 = { 1, 0, 0 };
	std::vector<double> C4 = { 0, 1, 0 };
	double tp_4 = TripleProduct(A4, B4, C4);
	std::cout << "Exercise 1 (d)" << '\t';
	std::cout << tp_4 << std::endl;
	// volume of a parallelpipped
	std::vector<double> A5 = { 3, 4, 1 };
	std::vector<double> B5 = { 2, 3, 4 };
	std::vector<double> C5 = { 0, 0, 5 }; 
	double tp_5 = TripleProduct(A5, B5, C5);
	std::cout << "Exercise 2" << '\t';
	std::cout << tp_5 << std::endl;
	// volume of a parallelpipped
	std::vector<double> A6 = { 3, 2, 1 };
	std::vector<double> B6 = { 4, 2, 1 };
	std::vector<double> C6 = { 0, 1, 4 };
	std::vector<double> D6 = { 0, 0, 7 };
	std::vector<double> AB = { -1, 0, 0 };
	std::vector<double> AC = { 3, 1, -3 };
	std::vector<double> AD = { 3, 2, -6 };
	std::cout << "Exercise 3" << '\t';
	double tp_6 = TripleProduct(AB, AC, AD);
	std::cout << tp_6 << std::endl;
	// volume of a tetrahedron
	std::vector<double> AB1 = { 1, 1, 0 };
	std::vector<double> AC1 = { 1, -1, 0 };
	std::vector<double> AD1 = { 0, 0, 2 };
	std::cout << "Exercise 4" << '\t';
	double tp_7 = TripleProduct(AB1, AC1, AD1) / 6.0;
	std::cout << fabs(tp_7) << std::endl;
	std::vector<double> P1 = { 0, 0, 0 };
	std::vector<double> P2 = { 1, 1, 0 };
	std::vector<double> P3 = { 3, 4, 0 };
	std::vector<double> P4 = { 4, 5, 0 };
	std::vector<double> P5 = { 0, 0, 1 };
	std::vector<double> Q1 = { 1, 1, 0 };
	std::vector<double> Q2 = { 2, 3, 0 };
	std::vector<double> Q3 = { 1, 1, 1 };
	std::cout << "Exercise 5" << '\t';
	double tp_8 = TripleProduct(Q1, Q2, Q3);
	std::cout << fabs(tp_8) << std::endl;
	std::vector<double> A10 = { 1, 1, 1 };
	std::vector<double> B10 = { 2, 4, -1 };
	std::vector<double> C10 = { 1, 1, 3 };
	double tp_10 = TripleProduct(A10, B10, C10);
	std::vector<double> D10 = { 0 };
	VectorProduct(A10, B10, D10);
	double magnitude = sqrt(InnerProduct(D10, D10, 3));
	std::cout << "Exercise 10" << '\t';
	std::cout << tp_10 / magnitude << '\t';
	std::cout << 2.0 * sqrt(38.0) / 19.0 << std::endl;
}

int main()
{
	Exercises_Section_1_13_1_Triple_Products();
	return 0;
}

Unknown's avatar

Author: jamespatewilliamsjr

My whole legal name is James Pate Williams, Jr. I was born in LaGrange, Georgia approximately 70 years ago. I barely graduated from LaGrange High School with low marks in June 1971. Later in June 1979, I graduated from LaGrange College with a Bachelor of Arts in Chemistry with a little over a 3 out 4 Grade Point Average (GPA). In the Spring Quarter of 1978, I taught myself how to program a Texas Instruments desktop programmable calculator and in the Summer Quarter of 1978 I taught myself Dayton BASIC (Beginner's All-purpose Symbolic Instruction Code) on LaGrange College's Data General Eclipse minicomputer. I took courses in BASIC in the Fall Quarter of 1978 and FORTRAN IV (Formula Translator IV) in the Winter Quarter of 1979. Professor Kenneth Cooper, a genius poly-scientist taught me a course in the Intel 8085 microprocessor architecture and assembly and machine language. We would hand assemble our programs and insert the resulting machine code into our crude wooden box computer which was designed and built by Professor Cooper. From 1990 to 1994 I earned a Bachelor of Science in Computer Science from LaGrange College. I had a 4 out of 4 GPA in the period 1990 to 1994. I took courses in C, COBOL, and Pascal during my BS work. After graduating from LaGrange College a second time in May 1994, I taught myself C++. In December 1995, I started using the Internet and taught myself client-server programming. I created a website in 1997 which had C and C# implementations of algorithms from the "Handbook of Applied Cryptography" by Alfred J. Menezes, et. al., and some other cryptography and number theory textbooks and treatises.

Leave a comment