Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Floor of the log equation: s = (floor(log10(x))+1)*x - round((10^(floor(log10(x))+1)-10)/9)

13 views
Skip to first unread message

nepomucen...@gmail.com

unread,
May 19, 2013, 2:20:13 PM5/19/13
to
Hi guys! I need your help to solve this equation:

I need to find 'x' for a given 's'. Both of them are natural numbers (>0).

I don't know how to handle the floor term.

[octave/matlab format]
s = (floor(log10(x))+1)*x - round((10^(floor(log10(x))+1)-10)/9);

[or TeX}
s = \left( \lfloor\log(x)\rfloor+1 \right)x - \frac{10^{\lfloor\log(x)\rfloor+1}-10}{9}

[or image]
http://postimg.org/image/r5fd2enll/


Exact or approximate values are good.

Is there a solution? How do I solve it?

Are there any methods to search & find a solution?

Regards,

Carlos

James Waldby

unread,
May 20, 2013, 12:23:30 PM5/20/13
to
On Sun, 19 May 2013 11:20:13 -0700, nepomucenocarlos68 wrote:

> Hi guys! I need your help to solve this equation:
>
> I need to find 'x' for a given 's'. Both of them are natural numbers (>0).
>
> I don't know how to handle the floor term.
>
> [octave/matlab format]
> s = (floor(log10(x))+1)*x - round((10^(floor(log10(x))+1)-10)/9);
>
> [or TeX}
> s = \left( \lfloor\log(x)\rfloor+1 \right)x - \frac{10^{\lfloor\log(x)\rfloor+1}-10}{9}
>
> [or image]
> http://postimg.org/image/r5fd2enll/
>
>
> Exact or approximate values are good.
>
> Is there a solution? How do I solve it?

Your image and tex forms show log() in some cases where the octave/matlab
form shows log10(); in following I ignore that inconsistency (which
doesn't affect the method outlined) and write l() to stand for log to
some base.

A closed-form solution giving x in terms of s may be difficult to find,
but if you can get some reasonably-close estimates x1, x2 of x such that
s is bounded by s(x1) and s(x2), then you can do a binary or other search
to find an x0 with s = s(x0), or perhaps the range of x values that yield
s. Anyhow, ignoring the floor and round functions and supposing logs are
base 10, the expression may be like

s = x*l(x) + x - ( 10*10^l(x) - 10 )/9 [5]

so s ~ x*l(x) + x - 1.1*x - 1.1 [6]

so s ~ x*l(x). [7]

According to <http://en.wikipedia.org/wiki/Lambert_W_function#Example_4>,
approximation [7] is solved by

x = e^W(s*ln(10)) [8]

You could compute values of x(s) using [8] for a couple of values of
s, and then search. Or via some of the other Lambert-function examples,
solve [6] to get more accurate starting values of x before the search.

--
jiw
Message has been deleted
Message has been deleted

Carlos Nepomuceno

unread,
May 22, 2013, 11:09:34 PM5/22/13
to
Thank you Jim! I ended up developing a search algorithm for that like you've suggested.

Since I don't have log(x) I calculate x using log(s). If log(x(s)) < log(s) then I recalculate using log(x(s)) and keep doing that until both have the same value.

I didn't manage to prove it's correctness but it works! ;)
0 new messages