The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Need some math help.

Deviant HandsDeviant Hands __BANNED USERS regular
edited December 2007 in Help / Advice Forum
I need to put together some formula that, as a function of time, will gradually turn one number into another number. And the larger the original number is, the longer it should take. I'm having trouble coming up with it for some reason. Help?

Deviant Hands on

Posts

  • amateurhouramateurhour One day I'll be professionalhour The woods somewhere in TennesseeRegistered User regular
    edited December 2007
    I need to put together some formula that, as a function of time, will gradually turn one number into another number. And the larger the original number is, the longer it should take. I'm having trouble coming up with it for some reason. Help?

    Do you have some examples of formulas you've started with? Not a lot of people here are just going to solve it for you when it sounds like they're doing your homework.

    amateurhour on
    are YOU on the beer list?
  • Deviant HandsDeviant Hands __BANNED USERS regular
    edited December 2007
    I need to put together some formula that, as a function of time, will gradually turn one number into another number. And the larger the original number is, the longer it should take. I'm having trouble coming up with it for some reason. Help?

    Do you have some examples of formulas you've started with? Not a lot of people here are just going to solve it for you when it sounds like they're doing your homework.

    There are no examples. This is part of a code I'm working on. Up until now, what I was doing was finding out a certain value using 2 other variables I have, multiplying it by a time tracking variable and subtracting it until I eventually reached a constant known value, of 0. The problem is I'm trying to do this not just for 0, but for any value X.

    Deviant Hands on
  • amateurhouramateurhour One day I'll be professionalhour The woods somewhere in TennesseeRegistered User regular
    edited December 2007
    okay, so, for example, you need a formula that would, over time, turn the number one into the number two, but not by specific time measurements?

    amateurhour on
    are YOU on the beer list?
  • Deviant HandsDeviant Hands __BANNED USERS regular
    edited December 2007
    yes

    Deviant Hands on
  • WillscottWillscott Registered User regular
    edited December 2007
    so, something like:

    f(t) = a + (b-a)*t/a

    so that f(0)=a
    f(a)=b

    meaning a bigger a results in a slower transition.

    Willscott on
  • amateurhouramateurhour One day I'll be professionalhour The woods somewhere in TennesseeRegistered User regular
    edited December 2007
    yes

    alright, so you've got x, and x has to become y, over the course of z.

    why not just set up a factor system, with an a to z arrangement?

    Like as a becomes b, use a time factor of say, one minute, then for b to become c, plug the formula for a (squared)

    Does that make sense, or is that not what you're looking for?

    edit: beat'd

    also, double checked, and it works. I input 1 for (a) and 2 for (b) and as 0, 1, and 2 for t. f(t) increased each time.

    amateurhour on
    are YOU on the beer list?
  • Deviant HandsDeviant Hands __BANNED USERS regular
    edited December 2007
    I'll try this in a bit. I just hope it will look natural for when neither a or b is staying constant.

    Deviant Hands on
  • WillscottWillscott Registered User regular
    edited December 2007
    While I'm not sure exactly what you're doing, I'm going to guess that you might be more satisfied with:

    f(t)=a+(b-a)t/abs(b-a)

    abs here is the absolute value

    this will transition from a to b, and it's 'speed' will be based on how far apart the two numbers are.

    the function will be smooth as a and b are moving, but you'll have to worry about you're time scale, because as the numbers change the time for the transition to complete will also change.

    Willscott on
  • Deviant HandsDeviant Hands __BANNED USERS regular
    edited December 2007
    Willscott wrote: »
    While I'm not sure exactly what you're doing, I'm going to guess that you might be more satisfied with:

    f(t)=a+(b-a)t/abs(b-a)

    abs here is the absolute value

    this will transition from a to b, and it's 'speed' will be based on how far apart the two numbers are.

    the function will be smooth as a and b are moving, but you'll have to worry about you're time scale, because as the numbers change the time for the transition to complete will also change.

    This could be a problem since t could very well end up larger than abs(b-a), as b and a change.

    Deviant Hands on
  • ecco the dolphinecco the dolphin Registered User regular
    edited December 2007
    Tried something like:

    f(t) = b + (a - b) e ^ (-t/k)

    Where:

    * f(0) = a
    * f(infinity) = b
    * k is a function of a - the larger a gets, the larger k gets.
    For example, k = a, although that particular relationship has the disadvantage that a cannot equal 0.
    * f(3k) will get you within 5% of the final answer

    ?

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • Deviant HandsDeviant Hands __BANNED USERS regular
    edited December 2007
    I'll have to take a closer look at that

    Deviant Hands on
Sign In or Register to comment.