473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

logarithmic interpolation

Hi, I have a program which reads a file containing integers in [0,10].
The program reads the value of a variable every 2 seconds, then maps it
to another interval, say [20,22000], obtaining a new value.
I already have a function which updates the variable, gradually
changing from the old one to the new one during the 2 seconds, which
uses a linear function.
Know I need to make the value of the variable change between old and
new in a "logarithmic way", that is the values between old and new must
follow a logarithmic scale.
How can I do that?

Jan 18 '07 #1
6 12287
different wrote:
Hi, I have a program which reads a file containing integers in [0,10].
The program reads the value of a variable every 2 seconds, then maps it
to another interval, say [20,22000], obtaining a new value.
I already have a function which updates the variable, gradually
changing from the old one to the new one during the 2 seconds, which
uses a linear function.
Know I need to make the value of the variable change between old and
new in a "logarithmic way", that is the values between old and new must
follow a logarithmic scale.
How can I do that?
This is not a question about C but about elementary arithmetic. I will
offer an explanation but it is al; off-topic in comp.lang.c and should
not be replied to.

<ot>
You are looking for a function that maps a linear variable x onto an
exponential variable y.
y = A*exp(bx)
using a for log(A), this is the same as
log(y) = a + bx
We have a form with two unknowns and we have two data points:
log(20) = a + 0*b
log(22000) = a + 10b
so we know immediately that
a = log(20)
or A = 20
and that
b = (log(22000) - log(20)) / 10
or
b = log(1100) / 10
so the mapping is
log(y) = log(20) + x * log(1100)/10

y = 20 * pow(1100, x/10);

</ot>
Jan 18 '07 #2
"different" <ci**********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
Hi, I have a program which reads a file containing integers in [0,10].
The program reads the value of a variable every 2 seconds, then maps it
to another interval, say [20,22000], obtaining a new value.
I already have a function which updates the variable, gradually
changing from the old one to the new one during the 2 seconds, which
uses a linear function.
Know I need to make the value of the variable change between old and
new in a "logarithmic way", that is the values between old and new must
follow a logarithmic scale.
How can I do that?
sci.math and related groups have a large pool of bored mathematicians and
students who will gladly address such topics.

--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
Jan 18 '07 #3
David T. Ashley wrote:
"different" <ci**********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
Hi, I have a program which reads a file containing integers in [0,10].
The program reads the value of a variable every 2 seconds, then maps it
to another interval, say [20,22000], obtaining a new value.
I already have a function which updates the variable, gradually
changing from the old one to the new one during the 2 seconds, which
uses a linear function.
Know I need to make the value of the variable change between old and
new in a "logarithmic way", that is the values between old and new must
follow a logarithmic scale.
How can I do that?

sci.math and related groups have a large pool of bored mathematicians and
students who will gladly address such topics.
They might even point him to this:
http://www.mpip-mainz.mpg.de/~desern...og_interpol.ps
--
David T. Ashley (dt*@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
Jan 19 '07 #4
Sorry, I know that it was OT, but I always tried sci.math and another
forum about algorithms, but they did not give me an answer in one week.
Thank you for the reply.

On 18 Gen, 19:26, Martin Ambuhl <mamb...@earthlink.netwrote:
different wrote:
Hi, I have a program which reads a file containing integers in [0,10].
The program reads the value of a variable every 2 seconds, then maps it
to another interval, say [20,22000], obtaining a new value.
I already have a function which updates the variable, gradually
changing from the old one to the new one during the 2 seconds, which
uses a linear function.
Know I need to make the value of the variable change between old and
new in a "logarithmic way", that is the values between old and new must
follow a logarithmic scale.
How can I do that?This is not a question about C but about elementary arithmetic. I will
offer an explanation but it is al; off-topic in comp.lang.c and should
not be replied to.

<ot>
You are looking for a function that maps a linear variable x onto an
exponential variable y.
y = A*exp(bx)
using a for log(A), this is the same as
log(y) = a + bx
We have a form with two unknowns and we have two data points:
log(20) = a + 0*b
log(22000) = a + 10b
so we know immediately that
a = log(20)
or A = 20
and that
b = (log(22000) - log(20)) / 10
or
b = log(1100) / 10
so the mapping is
log(y) = log(20) + x * log(1100)/10

y = 20 * pow(1100, x/10);

</ot>
Jan 19 '07 #5

different napisal(a):
Hi, I have a program which reads a file containing integers in [0,10].
The program reads the value of a variable every 2 seconds, then maps it
to another interval, say [20,22000], obtaining a new value.
I already have a function which updates the variable, gradually
changing from the old one to the new one during the 2 seconds, which
uses a linear function.
Know I need to make the value of the variable change between old and
new in a "logarithmic way", that is the values between old and new must
follow a logarithmic scale.
How can I do that?
Instead of the function log(x), rather you have
to use the following one: log(x - 1), for x >= 0.

Then the interpolation formula for x in [x_1,x_2]
with ratio f = a/(a+b), looks as follows:

(log(x_2 -1) - log(x - 1)) / (log(x - 1) - log(x_1 - 1)) = (1/f) - 1

After a simple calculation one can get

x = (x_1 - 1)^{f - 1} * (x_2 - 1)^{f} + 1 ,

what you expect.

Best Regards,
Z. Karno

Jan 19 '07 #6

Zbigniew Karno napisal(a):
different napisal(a):
Hi, I have a program which reads a file containing integers in [0,10].
The program reads the value of a variable every 2 seconds, then maps it
to another interval, say [20,22000], obtaining a new value.
I already have a function which updates the variable, gradually
changing from the old one to the new one during the 2 seconds, which
uses a linear function.
Know I need to make the value of the variable change between old and
new in a "logarithmic way", that is the values between old and new must
follow a logarithmic scale.
How can I do that?

Instead of the function log(x), rather you have
to use the following one: log(x - 1), for x >= 0.

Then the interpolation formula for x in [x_1,x_2]
with ratio f = a/(a+b), looks as follows:

(log(x_2 -1) - log(x - 1)) / (log(x - 1) - log(x_1 - 1)) = (1/f) - 1

After a simple calculation one can get

x = (x_1 - 1)^{f - 1} * (x_2 - 1)^{f} + 1 ,

what you expect.

Best Regards,
Z. Karno
Incorrect.
The sign - should be replaced by +.

So, the following function has to be used:
log(x + 1), for x >= 0.
In this case, the interpolation formula looks as
follows:
(log(x_2 +1) - log(x + 1)) / (log(x + 1) - log(x_1 + 1)) = (1/f) -
1.
Thus
x = (x_1 + 1)^{f -1} * (x_2 + 1)^{f} - 1 .

Regards,
Z. Karno

Jan 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dave.harper | last post by:
I'm relativly new to C++, and have been looking for a way to interpolate data (i.e. a table indexed by 2 arrays, or just an array indexed by another array). I haven't been able to find an easy way...
14
by: Charles Banas | last post by:
I'm not sure if this is the right place to ask about this, but I've seen several posts in the past regarding Akima's Bivariate Interpolations routines, and i'm wondering if someone can give me some...
3
by: Jonas Ernst | last post by:
Hi, Can somebody give me some hints how to do a line interpolation without using floating point arithemtics? The function shall do a linear interpolation between 2 points (line interp?) and...
2
by: Kun | last post by:
I have an html form that takes dates and inserts them into a mysql file. Currently, users have to type in dates in the yyyy-mm-dd format. As of now, this process works with the sql. However, I...
5
by: xandra | last post by:
i understood the concept of interpolation search. but i couldn't understand what would be the steps for that search. for example, if i'm searching for J in this file A A B E F H J M N N N N O P P...
5
by: different | last post by:
Hi, I have a program which reads a file containing integers in . The program reads the value of a variable every 2 seconds, then maps it to another interval, say , obtaining a new value. I already...
0
by: MonkeeSage | last post by:
There are several string interpolation functions, as well as string.Template. But here's yet another. This one emulates ruby's inline interpolation syntax (using #{}), which interpolates strings as...
0
ncochran
by: ncochran | last post by:
I need to create a windows application that will allow me to enter values for a triple linear interpolation. The program should output the answer to the center label when the user presses the "Go"...
10
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem...
6
by: Sunny | last post by:
Hi Is there a way to find a proper distance between large numbers. For example, if i have a set of numbers like: 10, 40, 80, 100, 500, 10000 Now if I have to create a break points between these...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.