Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Any reasonable way to do this??

  • 13-01-2014 07:11PM
    #1
    Registered Users, Registered Users 2 Posts: 32,387 ✭✭✭✭


    I need to program a way to do the following, with some constraints on how.

    Given real numbers X and Y where X < Y, I need to create 10 exponential steps from X to Y which would be graphically represented somethingexpcdf.gif like this:

    So, lets suppose X is 1.5 and Y is 2.5. I need a simple (non-recursive) equation which spits out 10 exponentially decreasing steps from 1.5 to 2.5 ..

    The best I can come up with is something like:
    F(t) = X + X(e^rt) where r is the rate and t is the step number....

    But that falls down in that is doesnt consider Y at all.
    It describes the write sort of arc but its not really what I'm looking for.


    I've been looking at this for so long I cant see the wood for the trees I feel...


Comments

  • Registered Users, Registered Users 2 Posts: 2,149 ✭✭✭ZorbaTehZ


    If I follow you correctly, then this may work

    [latex]F(t)=\log \left(\frac{1}{10} t \left(e^Y-e^X\right) + e^X\right)[/latex]

    Edit: the plus has disappeared (on my screen at least), so the function is F(t)=\log \left(\frac{1}{10} t \left(e^Y-e^X\right) + e^X\right).


  • Registered Users, Registered Users 2 Posts: 338 ✭✭ray giraffe


    To make each step half the size of the previous step do:

    [latex]\displaystyle F(t) = X + (Y-X) \left( \frac{1-0.5^t}{1-0.5^{10}} \right)[/latex]

    For X=5 and Y=14:

    5
    9.504398827
    11.75659824
    12.88269795
    13.4457478
    13.72727273
    13.86803519
    13.93841642
    13.97360704
    13.99120235
    14



    To make each step a quarter of the previous step do:

    [latex]\displaystyle F(t) = X + (Y-X) \left( \frac{1-0.25^t}{1-0.25^{10}} \right)[/latex]

    For X=5 and Y=14:

    5
    11.75000644
    13.43750805
    13.85938345
    13.9648523
    13.99121951
    13.99781132
    13.99945927
    13.99987125
    13.99997425
    14

    t runs from 0 to 10, so that's 11 numbers (with 10 gaps)

    Ray :)


  • Registered Users, Registered Users 2 Posts: 32,387 ✭✭✭✭DeVore


    OFFS!!!! I was so close to that and turned back from it! :)

    Many thanks Ray, that looks exactly like what I need!! And thanks Zorba, thats a very comprehensive answer too!


Advertisement