Jump to content
  • Advertisement
Sign in to follow this  
hyn

Equation help

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

*please see my new question below* [Edited by - hyn on August 18, 2005 5:39:21 PM]

Share this post


Link to post
Share on other sites
Advertisement
I'm no mathematician, and i'm a bit unsure what you mean- but this may be the sort of thing you are talking about:

F(Xn) = Xn-1 * Y

where Y is a varying value and Xn-1 is the answer from the previous iteration

so if the intial value of x is 200 (the value for X0) and the value of Y is constantly at 0.5 - you should get the following results:

N____Xn-1______Y______Xn_____
1____200_______0.5____100____
2____100_______0.5____50_____
3____50________0.5____25_____
4____25________0.5____12.5___

...and so on

Hope this helps,
Darragh

Share this post


Link to post
Share on other sites
Thanks for your help.

I don't think Xn-1 is neccesary, since I shouldn't need an input from a previous calculation.

I think I've messed up forming up my question, so I'll try again:


I want to find a number between 0.4 (or so) and 1, from a function, f(x).


EDIT: actually, x doesn't have to have limits..

f(1000) = 0.25
f(900) = 0.28
f(700) = 0.3
f(500) = 0.5
f(200) = 0.8
f(100) = 0.9
f(50) = 0.95
f(1) = 0.99
f(0.5) = 0.999

Then I can just multiply x by f(x) to get what I need.


Thanks,

hyn

Share this post


Link to post
Share on other sites
For the specific values you gave:
f(x) = 1 - (x / 500) * 0.6
will give a linear range of values intersecting 0.4 at 500 (f(500) = 0.4) and 1 at 1 (f(1) = 1). This doesn't necessarily satisfy f(200) = 0.8; if you definitely need that to be true, it becomes a quadratic function.

EDIT: Okay, so you changed the rules. This is more tricky, since you appear to have an asymptote as x approaches 0, and a something-else-for-which-I-can't-remember-the-term as x approaches infinity. A variation on
1 - Cx
maybe?

[Edited by - TDragon on August 18, 2005 5:28:41 PM]

Share this post


Link to post
Share on other sites
Ah yes, I think i understand what you mean now. You want to have 0.4 as the lowest possible number produced by this function and 1.0 as the highest possible number.

I think this would do the trick:

f(x) = 0.4 + (0.6 / x )

So the folowing values should be produced:

x_______f(x)
1.0_____1.0
2.0_____0.7
3.0_____0.6
5.0_____0.52
10.0____0.46
100.0___0.406

As x grows larger the answer will verge towards 0.4 but never reach it ( in pure maths terms of course, with the finite precision of computers it will ). So long as you keep x >= 1.0 this should work- if x falls below 1.0 however the answer will grow to infinity as you get closer to 0.0 , which is not what you want.

Regards,
Darragh

Share this post


Link to post
Share on other sites

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!