Linear to logarithmic scale conversion

AI Thread Summary
To convert linear values to a logarithmic scale while normalizing them between 0 and 1, the formula x'i = (log(xi) - log(xmin)) / (log(xmax) - log(xmin)) can be used. This approach allows for the creation of log-log plots effectively. An example provided shows that with xmin and xmax set to 1 and 100, respectively, an input of xi equal to 10 results in x'i equal to 0.5, confirming the midpoint on a log scale. The discussion also touches on the programming language used, C++, which supports logarithmic functions. Implementing this formula in the program is the next step for the user.
jocasa
Messages
4
Reaction score
0
Hi!

I'm making a computer program that represents some quantities in a graph in this way:

x'i=(xi-xmin)/(xmax-xmin)

so that the possible values of x range from 0 to 1. This is a linear scale. I want to do the same with the logarithmic values of xi. That is, I want to implement a log scale in my graphs, also in the range from 0 to 1.

Can anyone tell me how to do it?

Thanks!
 
Mathematics news on Phys.org
jocasa said:
Hi!

I'm making a computer program that represents some quantities in a graph in this way:

x'i=(xi-xmin)/(xmax-xmin)

so that the possible values of x range from 0 to 1. This is a linear scale. I want to do the same with the logarithmic values of xi. That is, I want to implement a log scale in my graphs, also in the range from 0 to 1.

Can anyone tell me how to do it?

Thanks!

Welcome to the PF.

What language are you programming in? Does it have any math libraries that cover logarithms?
 
I'm using C++ and it has both log and log10 functions, that is, log in base e and log in base 10.

I'm not sure if I made myself clear in my first post. I want to be able to make log-log plots, transforming the resulting plot into the [0,1] interval.
 
jocasa said:
Hi!

I'm making a computer program that represents some quantities in a graph in this way:

x'i=(xi-xmin)/(xmax-xmin)

so that the possible values of x range from 0 to 1. This is a linear scale. I want to do the same with the logarithmic values of xi. That is, I want to implement a log scale in my graphs, also in the range from 0 to 1.

Can anyone tell me how to do it?

Thanks!
I think this will work:

x'i = (log(xi)-log(xmin)) / (log(xmax)-log(xmin))​
As a test, we can see that if xmin,max are 1 and 100, then xi=10 gives x'i=0.5. As it should, since 10 is halfway between 1 and 100 on a log scale.
 
Thanks! It makes sense to me. Now the problem is to implement it in the program, but I won't bother you with such a thing. Thanks again from Spain!
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Thread 'Imaginary Pythagorus'
I posted this in the Lame Math thread, but it's got me thinking. Is there any validity to this? Or is it really just a mathematical trick? Naively, I see that i2 + plus 12 does equal zero2. But does this have a meaning? I know one can treat the imaginary number line as just another axis like the reals, but does that mean this does represent a triangle in the complex plane with a hypotenuse of length zero? Ibix offered a rendering of the diagram using what I assume is matrix* notation...
Back
Top