Sliding scale range I need to code a calculator and I'm struggling with the correct mathematical approach. It's to determine how much profit you can make given the hours and startup cash available.
The example provided is as follows (lowest range and highest range). How can I turn this into a formula? It seems to be a curve, i.e. the first few hours yield the most, and the more time you spend, the less your profit becomes.
Hours: 1
Startup Cash: $10
Potential Profit: $100
Rate: $100 per hour

Hours: 20
Startup Cash: $500
Potential Profit: $1,000
Rate: $50 per hour

The user can change the hours and cash between the ranges above. The formula should calculate the Potential Profit given the Hours and Startup Cash.
 A: So you want a function that doesn't depend on the startup cash at all? And you want it to be an exponential function on the hours? So in that case I'll assume the form
$$
f(h) = h_0 + h_1 e^{kh}
$$
Where $h_0, h_1$ and $k$ are constants. In addition, we have the boundary conditions
$$
f(1) = 100 \qquad f(20) = 1~000
$$
And in addition, we want $f(0)=0$, which means $h_0+h_1= 0 \Rightarrow h_1 = - h_0$. Now we are left with the equations
$$
\left\{
\begin{array}{ccc}
h_0 \left(1 - e^{k\times 1} \right) &=& 100 \\
h_0 \left(1 - e^{k\times 20} \right) &=& 1000 \\
\end{array}
\right.
$$
Dividing the equations by each other gives us
$$
\frac{1-e^{20k}}{1-e^{k}} = 10 \qquad \Rightarrow \qquad k \approx -0.08544
$$
This was obtained with a numerical method. Now $h_0$ is easy to obtain
$$
h_0 = \frac{100}{1-e^k} = \frac{100}{1-e^{-0.08544}}\approx 1~221.12
$$
Therefore, the answer is
$$
f(h) = (1~221.12) \times (1-e^{-0.08544h})
$$
where $h$ is the hours spent. This function very closely gives the required results.
