This is relatively simple but I've been out of college for a bit and can't quite get the result I'm looking for no matter how I attack this and I'm sure I'm just forgetting a crucial concept that is the missing link.
What I want to know is how to solve for the exact deviation required so that a linear sequence can be formed using three numbers while ensuring that the spacing between each value in the sequence is constant. The first and last value in the sequence are always known, while the third number can fall anywhere in-between, and the sequence will always be ascending. This needs to be precise enough to work for non-integers as well.
For example, lets say the first number is 2.5, the last number is 13, and the number in the middle that I want to use as the target point is 7, which looks like:
Start of 2.5, end of 13, and target value of 7
I essentially just want to know what dx is in the previous image. For this basic example it isn't too hard to figure out that dx = 1.5 which forms the sequence:
{ 2.5, 4, 5.5, 7, 8.5, 10, 11.5, 13 }
and includes the extent (first and last) and target numbers as I require. Now obviously this problem will have an infinite number of solutions that will form their own series, as once you find the largest spacing required, you can always break up that spacing into fractions that are themselves evenly spaced. In this same example I could break the largest deviation required, 1.5, into thirds and end up with:
Largest spacing required split into thirds
where dx_1 = dx_2 = dx_3 = 0.5 and dx_1 + dx_2 + dx_3 = dx, forming the sequence:
{ 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, ... 12, 12.5, 13 }
which still satisfies my requirements, now just with a finer granularity.
So, I know that the solution will be some kind of series composed of the formula for the largest spacing required combined with a scalar n applied to the denominator, where n is any positive integer, and n = 1 will produce the equation for the largest deviation possible, while larger values of n will give equations with rational fractions of dx that produce a more finely spaced sequence when solved and applied.
Basically, I just need the general solution to the above example. A bonus would be a quick way to know how large of a sequence (number of values) will be formed by using this spacing, though I expect that will just require some simple algebraic rearrangement of the solution I described once I know it.
Thanks.
Let $a,b,m \in \mathbb{R}$ be your initial, final, and intermediate values, and let the distance of each spacing be $d \in \mathbb{R}_{>0}$. Paraphrasing the question, you want the sequence
$$ x_n = a+nd \quad(n \geq0) $$
such that $x_k = m, x_l = b$ for some $k < l$. If there exists such $l$, we would have
$$ b = a +ld $$
so $d = \frac{b-a}{l}$. Likewise for $k$, we would need $d = \frac{m-a}{k}$. This gives the following equation:
$$ \frac{b-a}{l} = \frac{m-a}{k} $$
and rewriting, $l = k\frac{b-a}{m-a}$ so in particular for an exact solution we would need $\frac{b-a}{m-a} \in \mathbb{Q}$. If that can be guaranteed, let $k \in \mathbb{N}$ such that $l = k\frac{b-a}{m-a}$ is a natural number, and let $d = \frac{b-a}{l}$.
In your example, if $a = 2.5, b = 13, m = 7$, $\frac{b-a}{m-a} = \frac{7}{3}$. Hence we can take $k =3$, thus $l = 7$ and $d = \frac{13-2.5}{7} = 1.5$.