Mathematica is a commercially available program that can solve math problems, and it has its own general-purpose programming language that is not limited to just math.
In June 2017, while working on the 12th edition of my book A Soliton and its owned Bions (Awareness and Mind), I had occasion to use Mathematica to help me with a specific math problem I had in my gravity algorithm. And in July 2017 I used Mathematica to write a program that tests my sphere-filling message-sending algorithm that is detailed in the pass_this_message_along() routine in subsection 3.8.5 in my book.
In total, I created three different Notebooks (Mathematica’s terminology). A Notebook filename is suffixed with “.nb”, and this file is a large, bulky text file. However, Mathematica has an option to save a Notebook in other formats, including “Plain Text (*.txt)”, and I used this option to create the following three .txt files which I hereby place in the public domain:
mathematica-for-footnote-23-gmr-vectors.txt : See the First Use of Mathematica in my Book section below, for a detailed explanation of this text file.
mathematica-for-footnote-23-compute-test-cases.txt : This allows one to give arbitrary values for (x1, y1, z1), (x2, y2, z2), and L, and then verify that the vector’s head-point (x3, y3, z3) was computed correctly. In effect, this tests whether or not Mathematica’s solution of the Solve[] in mathematica-for-footnote-23-gmr-vectors.txt is correct, and that I had written the rules for setting add_or_subtract correctly. After trying many different values for (x1, y1, z1), (x2, y2, z2), and L, my conclusion is that Mathematica’s solution is correct and I had written the rules for setting add_or_subtract correctly. See the First Use of Mathematica in my Book section below for an explanation of add_or_subtract.
mathematica-test-sphere-filling-messaging-algorithm.txt : As said above, this tests my sphere-filling message-sending algorithm that is detailed in the pass_this_message_along() routine in subsection 3.8.5 in my book. More specifically, this tests the selection code in that routine. The selection code determines which adjacent computing element(s), if any, to give the message to, based on two pieces of data: the message sender’s XYZ coordinate and the XYZ coordinate of the computing element that has the message and is running the pass_this_message_along() routine.
If you have Mathematica, you can copy the text in any of the three above Mathematica .txt files into an empty Notebook and then evaluate it and see the results. Do the following (these instructions are correct for version 11.1.1.0 Home Edition of Mathematica which is the version that I had when I wrote these instructions in August 2017):
On Mathematica’s menu, select: File: New: Notebook
Result: A blank Notebook page opens up.
Copy the entire text from one of the three above .txt files into that blank Notebook page.
At this point the copied text is now in that Notebook page. To evaluate that copied text, select on Mathematica’s menu: Evaluation: Evaluate Notebook
In the case of copying the text from mathematica-test-sphere-filling-messaging-algorithm.txt into the blank Notebook page: You will have to scroll down to the end of that copied text, if not already there, to see the result of that evaluation. Also, the only input variable for this test program is cubeWidth which is near the top of the copied text. In the .txt file it is set to a value of 31, which should take about a second to evaluate. If you change cubeWidth’s value to a substantially higher odd-number value, note that substantially more execution time will be needed (read the two comments—each comment is bracketed by (* and *)—immediately above the cubeWidth = 31; line in the .txt file).
In June 2017, while working on the gravity algorithm that is in my book, I wanted to know how to compute the head-point of a 3D vector when I knew three things about that vector (denote the XYZ coordinate of this vector’s head-point as (x3, y3, z3)):
The tail-point of the vector (denote as (x1, y1, z1)).
The length of the vector (denote as L).
The vector lies on a line defined by two different points: the tail-point of the vector which is (x1, y1, z1), and another point (x2, y2, z2) which can be anywhere in 3D space as long as it’s not the vector’s tail-point (x1, y1, z1)).
The first thing I tried to do, given the above three knowns, is find the solution on the internet. However, I wasn’t sure how to construct my search query, and after about an hour of search effort, I gave up and decided to try solving the problem of computing the vector’s head-point myself. I knew it was an algebra problem, described in my book as:
Note that the computed value of (x3, y3, z3) must satisfy two different equations. The first equation is the equation of a line when two different points on that line—in this case, (x1, y1, z1) and (x2, y2, z2)—are known: ((x3 − x1) ÷ (x2 − x1)) = ((y3 − y1) ÷ (y2 − y1)) = ((z3 − z1) ÷ (z2 − z1)). The other equation is the distance formula: L = square_root_of((x3 − x1)^{2} + (y3 − y1)^{2} + (z3 − z1)^{2}).
The text file mathematica-for-footnote-23-compute-test-cases.txt is my Mathematica code for computing the values of x3, y3, and z3—the coordinates of the wanted head-point (x3, y3, z3)—in terms of the known values (x1, y1, z1), (x2, y2, z2), and L. Note: any text that begins with “(*” and ends with “*)” is a comment.
However, getting back to my attempt to solve this algebra problem by myself, before I had Mathematica to solve it for me: Even though my algebra skills were rusty from lack of use, the rules I had learned decades ago came back to me as I worked on the problem, making many substitutions as I covered seven paper pages with my handwriting (I was solving for x3, in terms of (x1, y1, z1), (x2, y2, z2), and L). But after about two hours of work I still had a long way to go: the numerator part of the fraction under the square-root sign was finished (this is the (L^{2} × ((x2 − x1)^{2})) part), but there was still a lot of multiplying and more to do for the denominator part of the fraction under the square-root sign. At that point, considering that I had already spent about two hours doing algebra without double-checking any of that work, and seeing that I still had a lot more work to do for that denominator part, and realizing that if I had made, or will make, a mistake anywhere, my formula for computing x3 will be invalid, I put down the pen and paper and decided to look online for a program that can do algebra. I already knew about the existence of Mathematica and its creator Stephen Wolfram, and I went there first. They had a free trial version of the complete Mathematica product, which I downloaded. I then learned enough from the documentation that comes with that product to write the following Mathematica code, which, upon evaluation, gives the wanted solution:
Solve[{((x3 - x1)/(x2 - x1)) == ((y3 - y1)/(y2 - y1)) == ((z3 - z1)/(z2 - z1)), L == Sqrt[(x3 - x1)^2 + (y3 - y1)^2 + (z3 - z1)^2]}, {x3,y3,z3}, Reals]
Note: The vector’s head-point on the line defined by (x1, y1, z1) and (x2, y2, z2), will be, relative to the vector’s tail-point, pointing in the same direction as the direction from the vector’s tail-point (x1, y1, z1) to point (x2, y2, z2). However, when I wrote the above Solve[] I wasn’t thinking about this additional constraint and how to specify it in the above Solve[], so the above Solve[] gives for its solution of, for example, z3, both the (z1 + square_root_of()) solution and the (z1 − square_root_of()) solution. To understand what I am referring to, see “The rules” for the add_or_subtract variable beneath paragraph p24 in footnote 23 in my book.