Writing a Science Fiction Novel and want to ensure my math and science within the novel remain accurate, respectful, and authentic.
3 次查看(过去 30 天)
显示 更早的评论
Hello!
I am not a very smart person, but I am writing a novel where my main character is... So, I've come here for help!
The Ask:
- The Sequence: 12 terms whose sum is 720, featuring a decay rate, can be reversible, and are governed by a damped harmonic oscillator equation ie: [108, 88, 92, 76, 80, 68, 64, 56, 40, 32, 8, 8]
The Exposition:
My novel is called The Repercussionist. It is first and foremost an allegory of grief. But there are some problems in the novel my main character is faced with, and I want to ensure that I use data, equations, solutions, math and science that remain respectful to the people who dedicate their lives to such pursuits. The novel touches on quantum mechanics, harmonics, time dilation, exponential growth, neurology, and sequencing. I am first going to list the areas in my novel that are most impacted by math. I'll give very brief descriptions in this section. Then I will break down the problems list by adding the data I have been working with thus far, and include any MATLAB codes I had attempted to run. Finally, I will give some context to the novel itself and provide relevant excerpts.
The Problems:
- The Sequence: a string of integers that represent intervals between the pulses of a machine that has initiated unexpectedly.
(Realizing how long this had become, I removed the other problems I needed help with, for anyone interested in helping with those, I will happily comment to provide them.)
Previous Attempt:
I previously asked a question to help identify a rule that governed a sequence of numbers. The series of terms I provided: [108, 88, 92, 76, 80, 68, 64, 56, 40, 32, 8, 8] was given to me by ChatGPT4 when prompted to provide a series of intervals, in seconds, for the pulses of an off kilter damped harmonic oscillator. The answers given to that question highlighted my own ignorance in that I didn't even know what I was looking at to know that those numbers did not make sense for that problem. Here is what GPT had given me:
% Assuming you have the Curve Fitting Toolbox installed:
% Generate time variable, I'm using 0-11 as the time interval here, adjust as needed
t = 0:11;
% Your rounded data, replace with your own data
y = round([38.5482, 38.6320, 40.7562, 45.9135, 54.8820, 67.7717, 83.4183, 98.7068, 108, 102.9626, 73.1756, 8]);
% Define the under-damped harmonic function
underDampedHarmonic = @(C, γ, Ω, Φ, t) C*exp(-γ*t).*cos(Ω*t + Φ);
% Provide initial guesses for the parameters, here I'm using ones
initialGuess = [1, 1, 1, 1];
% Fit the model to your data
fittedModel = fit(t', y', underDampedHarmonic, 'StartPoint', initialGuess);
% Display the fitted parameters
disp(fittedModel);
And:
% Optimization
initParams = [100, 1, 0.1, 0];
options = optimoptions('fmincon','Display','iter');
params = fmincon(@costFunction, initParams, [], [], [], [], [], [], @constraints, options);
% Define costFunction
function sse = costFunction(params)
%function sse = costFunction(params)
a = params(1);
b = params(2);
k = params(3);
phi = params(4);
% Observed data
x = 1:12;
y_obs = [108, 88, 92, 76, 80, 68, 64, 56, 40, 32, 8, 8];
% Model prediction
y_pred = a*sin(b*x + phi).*exp(-k*x);
% Sum of squared residuals
sse = sum((y_obs - y_pred).^2);
end
% Define constraints
function [c, ceq] = constraints(params)
%function [c, ceq] = constraints(params)
a = params(1);
b = params(2);
k = params(3);
phi = params(4);
% Define the constraints
x = 1:12;
y = a*sin(b*x + phi).*exp(-k*x);
c = [min(y)-8, 200-max(y)]; % Inequality constraints
ceq = sum(y) - 720; % Equality constraints
end
But obviously beginning with skewed data, I was never going to get a real result. Which is unfortunate. But alas, here we are.
For those curious, this was my prompt to GPT that created that output:
"Help me to create a sequence of numbers within these constraints:
Parameters:
- The sequence consists of 12 whole numbers.
- The sequence is reversible, meaning it can be generated from a clear rule.
- The numbers in the sequence sum up to 720 seconds.
- We do not use any arbitrary values
- Each number, if it must contain a decimal is no more than the tenths place.
Preferable but not required:
- each value is either deterministic or derived from something
- The sequence exhibits a decaying pattern, the numbers get smaller as they approach the 12th term
- The rule that is derived from the pattern can be related to a harmonic oscillator, or Delta wave function, or time crystals, or a resonance chamber
- The sequence is comprised of whole, positive integers
Optional extra credit:
- The sequence can be described by two formulas
Some important Info:
First, we know that the sum of an arithmetic sequence is given by the formula S = n/2 * (a + l), where n is the number of terms (12 in our case), a is the first term, and l is the last term. So the answer to a and I is 60, 60 with results branching from there. As we decrease I we have to increase a symmetrically. So 30, 90; 13,107; ...etc
Second, when we think about a harmonic oscillator or a wave function, one of the first things that might come to mind is a sinusoidal function, like a sine or cosine wave. This kind of function oscillates between positive and negative values, and its rate of change slows down as it reaches its maximum and minimum values. Considering we want positive, whole numbers and a decaying pattern, we might not want to directly apply a sinusoidal function. However, we could try to incorporate some of its characteristics into our sequence.
Here’s one idea:
- Start with a sequence where the difference between consecutive terms decreases, reflecting the decreasing “speed” of a harmonic oscillator or wave function as it reaches its maximum and minimum values.
- Incorporate a secondary “wave” of smaller variations on top of the main sequence, to mimic the behavior of a wave function. Here’s how this might look in practice: Let’s say we start with the sequence 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, which sums to 720. Then, we adjust the differences between the terms to create a decaying pattern. To do this, we might start with a large difference (like 10), and decrease this difference with each subsequent term: 70, 60, 50, 45, 40, 35, 35, 40, 45, 50, 60, 70. Now we have a sequence that decreases and then increases again, similar to a harmonic oscillator or wave function.
- However, it doesn’t quite fulfill the requirement for the sequence to decay overall, since the first and last terms are the same. To fix this, we could adjust the sequence to decay slightly over time. For example, we could subtract 1 from the first term, add 1 to the second term, subtract 2 from the third term, add 2 to the fourth term, and so on. This would give us: 69, 61, 48, 47, 38, 37, 37, 42, 47, 52, 62, 70. This sequence decreases and then increases again, and it also decays slightly over time. Additionally, the exact adjustments we made could be determined by a secondary sequence (the sequence of adjustments we made: -1, +1, -2, +2, -3, +3, etc.), which could be related to the behavior of a harmonic oscillator or wave function."
And here is an excerpt from what I wrote after recieving that as my base sequence:
"
...
23:58:32
He had a few problems and he couldn’t solve them all at once. ‘So, let’s compartmentalize.’ He knew he couldn’t discover what had initiated the sequence, but he was able to determine when it had booted up. He couldn’t measure the actual output of energy to determine the intensity of the waves, but he had been keeping track of each pulse, so he could identify their frequency. Somewhere, in the back of his mind, someone had been telling him it would come in handy.
So what he could solve, was the pattern. If he could predict the next pulse and avoid being rocketed back to the wall again, that would be swell. If he couldn’t, he could at least predict the decay rate and have a decent guess as to a window to make a break for it."
...
"Let’s look at what we know: Times. Monitor said system kicked on at 23:48:00. 23:49:48, When the first pulse hit. 23:51:16, According to the monitors, was the next. 23:52:48, Is when he first noticed it. 23:54:04, He realized they were picking up. 23:55:24, the pulse had become actually forceful. 23:56:32, The first time he was knocked into the wall, he didn’t believe it would be the last. 23:57:36 busted the lights. Well, the total time so far is something like nine and a half minutes, right? So… now what? Ok- let’s get more specific…"
...
"If the differences between each term are constant, then it is an arithmetic sequence. If the ratios of each term are constant, then it's a geometric sequence.
108, 88, 92, 76, 80, 68, 64...
Let's start there with arithmetic. Just good old subtraction.
88 - 108 = -20, 92 - 88 = 4, 76 - 92 = -16, 80 - 76 = 4, 68 - 80 = -12, 64 - 68 = -4
Welp.
Looking at the ratios between each term, that's not so bad either, basic division.
88/108 ≈ 0.81, 92/88 ≈ 1.05, 76/92 ≈ 0.83, 80/76 ≈ 1.05, 68/80 ≈ 0.85, 64/68 ≈ 0.94
Well shit.
Ok- that got us nowhere. Not geometric or arithmetic. Well, .81, .83, .85 is at least interesting. But not necessarily important. The differences between the differences were interesting, though, maybe that was the place to start.
An average absolute difference is calculated by summing all the absolute values of the differences and then dividing by the number of differences.
|108-88| = 20,
|88-92| = 4,
|92-76| = 16,
|76-80| = 4,
|80-68| = 12,
|68-64| = 4.
When you sum these up you get 60. And since there are 6 differences, you divide 60 by 6 to get the average absolute difference of 10. Interesting… But not necessarily important, yet. The absolute differences between each secondary difference are:
|-20-4| = 24,
|4-16| = 20,
|16-4| = 12,
|4-8| = 4.
Sum these up, you get 60. There are 4 differences here, so 60 divided by 4 is 15.
Ok, hold the phone. Hold the horses. Hold everything. That is peculiar, too. The sum of both differences is 60? That's not coincidental. That indicates a deeper pattern."
I am happy to rewrite that with an entirely different sequence. But I really don't know where to begin. The machine in the novel is fictional, but the information derived from it was meant to indicate that it was inspired by harmonic oscillators. Here is a layman's description of the machine. (The subsequent "pulses" are because of course, something goes wrong. The inner sphere accidentally creates a micro-blackhole and then we get to get all timey-wimey. (That's right, the novel is a time travel scifi. -But it does have a unique twist! It's accidentally sending back the consciousness of the scientist into his own mind in 12 minute recursions. So we get to have all kinds of fun.)
"In essence, the Delphi Machine is a marvel of quantum engineering designed to control the uncontrollable - time crystals. It’s split into two main phases. Phase one, called 'Genesis', is where we form and stabilize time crystals, a kind of quantum matter that oscillates in a pattern over time, just like a crystal's atomic pattern repeats in space. We then pump energy into these time crystals using special vibrational devices.
Phase two, named 'Exodus', is where the real fun begins. We jolt the time crystals, triggering them to release their stored energy. Then we focus this energy into a single point, a bit like focusing sunlight with a magnifying glass, only way more complicated. The end result is our new state of matter: PhotonicPlasmid.
Now, the machine has four key parts, or spheres.
Sphere 0 is like the heart of the operation. It's a highly reflective chamber made from fused silica that contains and controls the light used in our process. We can change how reflective it is, allowing us to control how much light gets in and stays in.
Sphere 1 is where the lasers live. They fire light into Sphere 0 when the computer says it's time, feeding the light whirlpool that's going on in there.
Sphere 2 is kind of the stage manager. It uses magnetic fields to spin the interior spheres in a way that ensures everything stays in sync, preventing any catastrophic resonance. Plus, it's built to withstand any external disturbances.
Finally, Sphere 3, the 'tricorn', is the brain. Housing a quantum computer, it precisely controls the lasers, the spinning of the spheres, and even the reflectivity of Sphere 0.
Put it all together, and you get the Delphi Machine: a quantum project that could revolutionize everything we know about time, energy, and maybe even the universe itself."
采纳的回答
John D'Errico
2023-7-14
As a response to the question asked, I think possibly you are going down the wrong path, because first, I see no reason why you need to use a sine wave, AND because getting a sine function to produce integer, or even rational values is quite difficult. Trig functions are by design, basically irrational. And when you throw in an exponential, it all goes to hell in that respect.
Can you generate a function that involves only integer or at worst, rational arithmetic, and has some properties that you may want to see? Possibly. For example, is there some simple function that generates a periodic series, yet returns integer results? This is not difficult. For exampel, we might do this:
N = 0:50;
S1 = mod(N,10);
plot(N,S1,'o-')
So a simple sawtooth function, but purely integer. There is no reason to invoke a sine wave. Next, we can make this vaguely more siusoidal. For example, we might do this:
S2 = 25 - abs(5 - mod(N,10)).^2;
plot(N,S2,'o-')
Again, I can certify that EVERY output there is a pure integer. Do you want it to be apparently damped in some way? This is a minor probem, because you cannot have an infinite sequence of integers that remains integer forever (and stays non-zero), yet also decreases towards zero. Eventually, you will hit zero, and then stay there. But we could do something like this, if the sequence is finite:
S3 = (25 - abs(5 - mod(N,10)).^2).*(50 - N);
plot(N,S3,'o-')
Again, we can prove that every element of that sequence is an exact integer.
S3
So a damped, quasi-periodic, and purely integer sequence. Note that to be purely integer, with each iteration the numbers are getting larger in magnitude. Such is life.
Another idea is to approach this from a far more number theoretic point of view. For example, pick some number a.
a = 3;
And another integer that is co-prime with a. I like 17.
M = 17;
Next, consider the powers of a, modulo M. One must be careful, since this operation will overflow a double pretty quickly.
N = 0:63;
S4 = ones(size(N));
for n = 1:N(end)
S4(n+1) = mod(S4(n)*a,M);
end
plot(N,S4,'o-')
In fact, this somewhat more random looking sequence will also be periodic, and it will have period no longer than than M-1. (A little number theory will allow you to prove that. Talk to a fellow named Fermat as a starter.)
reshape(S4,[16,4])
This could actually get you down the deep, dark, rabbit hole of number theory, depending on how far you want to take it.
Anyway my point is, you are going down the wrong path. You are trying to create a sequence from an exponentially damped sine wave, yet what you want are integers out the end. So you need to start with integers, and use functions that operate on integers, and produce integers as a result. Now it can be quite easy to generate the type of sequences you seem to want. I cannot possibly know what you are looking for in the end.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Condensed Matter & Materials Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!