Connecting Tech Pros Worldwide Help | Site Map

How to Write This Function

Member
 
Join Date: Nov 2008
Posts: 80
#1: Mar 22 '09
Hi,

I have a function y=1/x but I need it to return values like:

y=1.0 --> x=1.0
y=0.5 --> x=1.5

I guess I need a logarithmic function but how?

Thanks.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Mar 22 '09

re: How to Write This Function


Quote:

Originally Posted by serdar View Post

Hi,

I have a function y=1/x but I need it to return values like:

y=1.0 --> x=1.0
y=0.5 --> x=1.5

I guess I need a logarithmic function but how?

Any function that goes through those two points (1.0,1.1.0) and (1.5, 0.5) will do, even a simple linear function f(x) == 2-x would do fine. What exactly do you want?

kind regards,

Jos
Member
 
Join Date: Nov 2008
Posts: 80
#3: Mar 22 '09

re: How to Write This Function


I have a multiplier variable that changes based on a percentage value. With my current function (y=1/x) when we have 50% the multiplier is 2, which is too high for me.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#4: Mar 22 '09

re: How to Write This Function


Quote:

Originally Posted by serdar View Post

I have a multiplier variable that changes based on a percentage value. With my current function (y=1/x) when we have 50% the multiplier is 2, which is too high for me.

What would the values f(0) and f(infinity) be for your function?

kind regards,

Jos
Member
 
Join Date: Nov 2008
Posts: 80
#5: Mar 22 '09

re: How to Write This Function


Well the multiplier is actually a 'gain' value depends on the volume. So if the volume is 0 there is no need to calculate the gain.

gain=1/volume; (where volume>0 and volume<=1)
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#6: Mar 23 '09

re: How to Write This Function


x = - log(y) + 1 ??
y = 1 -> x = 1
y = .5 -> x = 1.30
y = .2 -> x = 1.70

or
x = -ln(y) + 1 ??
y = 1 -> x = 1
y = .5 -> x = 1.69
y = .2 -> x = 2.61
Member
 
Join Date: Nov 2008
Posts: 80
#7: Apr 12 '09

re: How to Write This Function


Thanks jkmyoung, I'll look deeper into that when I'm back working on the project.
Reply


Similar Algorithms / Advanced Math bytes