I'm asking this here as it's a problem that someone may have come across. I need to plot a curve with the following known values:

v1 - a starting value

Ideally I need a formula to calculate a value t, between t1 and t2, for any given value of v but my little brain is struggling.

Here is a formula. It may look a little complicated, but should be straightforward enough to implement on a computer.

Given a t between t1 and t2, define n as follows

n = [ln(t2-t)-ln(t2-t1)]/ln(1-h/100)

Then

f(t)=[v1 + (2^n-1)v2]/2^n

I can explain how I derived this expression if you are interested, but for now let's do a few calculations for sanity check.

When t=t1, we get n=0, and f(t)=v1, as required.

When t=t2, then strictly speaking the formula for n is underfined, but taking the limit you can say that n is infinity and f(t)=t2.

When t=t1+h(t2-t1), we get n=1 (assuming I did not make a mistake - check it!) and f(t)=(v1+v2)/2

When h=50, we obtain

n = [ln(t2-t)-ln(t2-t1)]/ln(1/2), which is the same as log to base 2 of (t2-t1)/(t2-t). In this case

2^n=(t2-t1)/(t2-t)

and after some simplification we obtain the formula

f(t)=[(t2-t)v1+(t-t1)v2]/(t2-t1)

which is a linear formula interpolating between f(t1)=v1 and f(t2)=v2.

Fantastic - thanks Turtle - I will plug this in and give it a whirl

Just to check I've got this right, this (what I think) is your formula in code:

let n = (Math.log(t2-t) - Math.log(t2-t1)) / Math.log(1-h/100)

It looks good (i.e. giving a nice straight line at h=50), but it's giving me values outside the v1 - v2 range. I wasn't quite sure how to transpose (2^n-1)v2 - I've assumed a multiplication?

Yes, it is multiplication. But just to be sure, let me emphasize that it is 2^n-1, not 2^{n-1}.

For example, if n=3, (2^n-1)v2 = 7 times v2.

So I think in your code the formula for y should probably be the following (but I am not familiar with this programming language)

y = (v1 + (Math.pow(2, n)-1) * v2) / Math.pow(2,n)

Excellent! That's done it.

Thank you so much, Turtle. I've been scratching my head for hours over that one.

I would be interested in understanding the logic but aware that you've already given a lot of your time, so feel free to point me at the right terms to Google.

I would not actually know what to Google. The idea is simple enough. Your condition says that

f[t1+0.01h(t2-t1)]=(v1+v2)/2

You can rewrite it as follows

f[t2 - (1-0.001h)(t2-t1)]=(v1+v2)/2

Now replace t1 with t2 - (1-0.01h)(t2-t1) and do the same calculation again. That is, write the condition that the value of f at h percentage of the way from the new t1 to t2 is the average of the value of f at the new t1 and at t2. After doing the calculation and simplifying, you get the formula

f[t2 - (1-0.001h)^2(t2-t1)]=(v1+3v2)/4

And by induction on n, you get the following formula for all positive integers n.

f[t2 - (1-0.001h)^n(t2-t1)]=[v1+(2^n-1)v2]/2^n

Now let t=t2 - (1-0.001h)^n(t2-t1). Then

f(t)=[v1+(2^n-1)v2]/2^n

where we need to express n in terms of t. If you take the definition of t above and solve for n, you will get our formula.

Yes, but it won't help you against the Combine.

Round of applause for Turtle!

round of applause

Yes, that is brilliant, thank you.

My next problem is reversing it to return a value t for any given value of y.

not sure Turtle has it right, check this out:

https://qph.fs.quoracdn.net/main-qimg-7beca9cf6c835bdfeabac3541a778973-pjlq

I have no idea what any of it means or does but in the internet sea of idiocy and cruelty I’m heartened by the cleverness and willingness to give help so I too applaud Turtle.

or Turtle has just aided the evil Lomax by unwittingly providing the final piece of the puzzle that brings AI to the point of singularity meaning by the end of January we will be hunkered down in burnt out shell holes while the machines hunt us to extinction. Could go either way really.

monkey! welcome back!

She makes a good point too. I suggest we hunt turtle down before he can do any more damage.

t = t2 - Math.exp( Math.log(1- 0.01h) * Math.log2((y1 - y2) / (y - y2)) + Math.log(t2-t1) )

Seems to do the trick. Excellent. Time to instigate Armageddon . . .