12
$\begingroup$

Given a number n, how would I convert this number into a logarithmic scale?

My logarithmic scale would range from 0 to 255 (I'm working with RGB colours), and I would expect values of n from 1 to 1,000,000.

Apologies if this is an easy question.

$\endgroup$

1 Answer 1

13
$\begingroup$

let $f(n)$ be the log function of n.

So a general log function can be written as $f(n)=k\log n +c$

where $k$ and $c$ are constants

$\implies 255=k\log {10^6}+c$

and $0=k\log {1}+c$

here is to the base 10

so $c=0$ and $k=255/6$

or here you can use any base and different values of k

so that $f(n)=\frac {255 \log n}{6}$ if the base is 10.

$\endgroup$
6
  • 2
    $\begingroup$ Thanks, that's great. How would I approach the problem if I expected values of n that ranged from 0 to 1,000,000 (since log 0 is undefined)? $\endgroup$ Oct 12, 2014 at 15:33
  • 1
    $\begingroup$ Then you can redifine your function as $f(n)=klog(p+n) + c (p=10^6) $ Here you can get values of k and c by substituting 0 and 255 in the place of $f(n)$ and $n=0, 10^6$ respectively. Don't forget to upvote and if satisfied mark as correct answer. $\endgroup$
    – Jasser
    Oct 13, 2014 at 6:36
  • 1
    $\begingroup$ What is p? And how can a function have p = 10^6 in it? $\endgroup$ May 11, 2015 at 15:52
  • 1
    $\begingroup$ p is just a number so that the value of log is defined even for n=0 case. U can take it as any number such that your function is always defined. Moreover if u do this there is nothing wrong going on because the function would still be logarithmic. @Boumbles $\endgroup$
    – Jasser
    Sep 11, 2015 at 15:58
  • 1
    $\begingroup$ @IanWarburton sorry to respond so so late.... thanks to Boumbies' I saw your comment. Are the ranges of logx and log(x+c) equal where c is any real constant. If yes, then taking p=10^6 should not mind u because the function would still be logarithmic. $\endgroup$
    – Jasser
    Sep 11, 2015 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .