At work I stumbled on a function for doing a log in base 2. After studying the function, I decided to try a similar approach to the exponential function.
We start with Taylor series. I'm not sure how James Gregory discovered infinite series or how Brook Taylor figured out a general method for constructing them back in the early 1700s, but they sure do come in handy in the age of computers. This topic is infamous amongst calculus 2 students, but although they were a lot of work, I rather enjoyed them. Let's first look at the Taylor series transform function:
The notation denotes the nth derivative of the function. The variable a is some starting point. Our function is . To preform the Taylor series, we need a list of the function's derivatives. For our function, that's easy: . Fill in the blanks, our our series becomes .
To see why this is useful, let's step back to the Maclaurin series for ex: . This series will work for any value of x. There's just one problem, which should be easy to see from looking at the function: n!. This value grows very rapidly, and it doesn't take long before we run out of floating point precision. This is why the Taylor series is better. We can speed the process of convergence by starting from some known point closer to x.
In order to implement this in software, we now need a known point. If a general ex is desired, then we are going to need several known points. I used some known limitation for the implementation. 64-bit double precision floating point has a range from 2-1024 to 21023. Any value outside of this range is too much to work with. Just blindly judging from a spreadsheet, I could see that useful range from was -50 < x < 708. To keep it simple, I just decided to have a whole number increments in the table. So 758 known entries must be known.
To generate these, I used a program I've been using more and more. It's called PARI/GP and is a computer algebra system. One of the fetchers is arbitrary precision arithmetic (i.e. the ability to calculate big numbers). I used the program to generate my table of known values with 50 digits of accuracy.
And here is the implementation:
Download the tables here.
If you follow the code, you will notice a couple of things. We can take advantage of the fact a summation is a loop. This speeds up two items, (a - x)n and n!. This is because and . Thus, we can accumulate the results similar just like with the summation—except instead of adding, we multiply. The upper limit on the loop is not infinity. The reality is, we only want as much precision as we can store. So once the loop has produced enough precision that the numbers no longer change, it stops. Also, the summation loop starts at 1, not zero. This is because of the factorial. 0! = 1, and 1! = 1. Rather then deal with this in the loop, I started with the second term and moved the results of the first term out of the loop. Evaluated, the first term of the loop comes out to be ea. The (-1)n means this is an alternating series—or that the sign is inverted on even/odd intervals. We can do that better with an if statement.. The loop is really . Note that k is some finite number based on the precision—usually less then 20.
My initial testing shows this function is accurate to about 12 digits.
I now have a really massive space ship. Now lets run the numbers to see what would be required to make it work, and how big it really is.
The outer ring has 100% gravity and contains 90 spheres for a total of 282 km2 (109 sq. miles). All the rings combine give a total of 540 spheres for 1,414 km2 (around 545 sq. miles), and with just the 6 sets rendered, 8,482 km2 (3,275 sq. miles)—a little less land area then the island of Island of Hawai*i.
The outer ring is for people. Assuming a population density of Beloit, Wisconsin (2,176.6 people/sq. mile), there could comfortably be 237,250 people. Up the density to that of New York City (27,440 people/sq. mile) and a total population of 2,445,960 people could be supported. If I had been able to render the full ship with 100 ring sets, the population could have been as high as 300 million people.
We can hold plenty of people, and there is a 5:1 ratio of auxiliary space to living space. The auxiliary space would be used to grow crops, and may be able to make more efficient use of the total cubic area of the spheres. It would seem we have enough space. So how much energy are we going to need in order to move this ship to the edge of the solar system?
First, we need to mass of this ship. This is going to be a very big number. To make things easier to estimate, lets just assume the mass of each sphere is about that if it were half filled with water. Why? Because we need a place to start, and water is fairly dense. I love the metric system for reasons such as this. The weight of 1 cubic meter of water is exactly 1,000 kg or 1 tonne (metric ton). Each sphere has a volume of around 4.1 billion cubic meters, and would have an estimated mass of 4.1 trillion kg. We have 3240 of these spheres for a grand total of 1.36x1016 kg—13.6 quadrillion kg. It's hard to comprehend this much mass because of it's scale.
Now that we know mass, we can determine the amount of energy required to keep it at a constant acceleration. Remember we want a constant acceleration of 9.81 m/s2 so that Earth's gravity is obtained from the linear acceleration. We need to know how much force is required to obtain this acceleration. The Newton unit is a measurement of force, and it is given in kg·m/s2. We have the mass in kg, and the acceleration in m/s2, so fill in the two numbers and we get 1.33x1017 or 133.1 quadrillion Newtons of force.
Now that we know how much force is needed for our constant acceleration, we need to know much much energy will be required to travel to the edge of the solar system. The unit of energy, the Joule, is kg·m2/s2. That is, how much force is being applied for the distance travel. We have force, and we know distance—50 AU or 7.5 trillion meters. So we need 995.9 octillion joules of energy. For comparison, a 1 megaton nuclear bomb contains 4.2 quadrillion Joules of energy. This craft requires the equivalent of 238 trillion 1 megaton devices.
So where does one come up with this huge quantity of energy? The common answer in sci-fi is to use the most dense energy form known—antimatter. Using mass-energy equivalence (yes, I'm about to invoke Einstein's famous E=mc2), 1 kg of mater, if converted to pure energy, contains 8.99x1016 or 89.9 quadrillion Joules of energy. That's the equivalent to the energy of a 21.5 megaton bomb—in just 1 kg. It's easy to see why sci-fi writers like antimatter, and if we could really produce it, we would indeed have an extremely dense form of energy.
Antimatter, however, doesn't convert into 100% usable energy. For those who are not familiar with antimatter, just understand that when mater and antimatter meet, they annihilate each other. The result is energy, transmitted in photons (electromagnetic energy—light, radio waves, ext.) and neutrinos. Neutrinos are useless as energy as they interact so weakly with matter their energy can not be captured. So 50% of the energy in antimatter is automatically lost. In addition, there is an efficiency loss on the engine—presumably some kind of rocket engine. Rocket science is a little difficult—it's rocket science. However, if we use the space shuttle as an example, it is known the rocket engines come out to be about 17% efficient. That is, 17% of the total energy stored in the fuel goes to moving the vehicle. The rest goes into making heat (most of the energy), light and noise. So lets assume our antimatter rockets can obtain 20% efficiency. Between the neutrinos and efficiency, we loss about 90% of of the energy in the fuel. But that's about all the better most cars do. The result is a total of 110.8 trillion kg of antimatter fuel is needed. This comes out to be less then 1% of the overall ship mass. Consider how massive the space shuttle is, and how much of that is just for fuel—this craft is pretty efficient.
To house this much fuel, we need to know how dense the fuel is. Lets assume we can make any kind of antimatter we desire. So anti-Iron would be a good choice. The density of iron is 7,874 kg/m3, and the properties of anti-iron should be similar (if not identical). A storage space of 14.1 billion cubic meters is required. For this, I added the 4 larger inner spheres, each with a radius of 6000 meters. Each would have a volume of 904.8 billion cubic meters—more then enough room for our fuel. Since this is antimatter fuel, some containment system would have to be in place. For how, like many other issues, I am ignoring this.
There we have it. One massive ship. But in theory, we could push it to the edge of the solar system. Honestly, I love running the numbers. I now have big spreadsheets full of equations so I can tweak values and see the results. And this is only one run of "the numbers".