Rewrite 0.ceil(x) in a way that wolfram alpha will accept it

ceiling-and-floor-functionswolfram alpha

I have been trying to put $0.\lceil{x}$ in wolfram alpha, but it keeps thinking that I am trying to type $0*\lceil{x}$. I've tried experimenting with the idea that when $0<x\le10$, I can write it as $\frac{\lceil{x}}{10}$, and when $10<x\le100$, I can write that as $\frac{\lceil{x}}{100}$. But to do that, I need a function that turns $x$ into its base, such that the base of 97 is 10, the base of 193 is 100, etc. Then I need to write $\frac{\lceil{x}}{base}$, and then that will be in a notation wolfram alpha will understand. Is there a way to get the base of any number $x$ easily? Also keep in mind that currently my highest math class is algebra 2, so if possible could you explain it in less advanced terms?

Best Answer

Disregard my answer below.

Type StringJoin["0", "x"] into Mathematica.


$$f(x) = \frac{\lceil x \rceil}{10^{\lfloor \log_{10} x \rfloor + 1}}, 0.1 ≤ x; \ f(x) = 0.1, 0 < x < 0.1$$

works.

As you were saying, $0$ point $x$ is $\lceil x \rceil$ divided by a suitable power of $10$. So a first attempt might be $10^{\lceil \log_{10} x \rceil}$, which shifts the decimal point left (making it smaller) by the number of digits of $x$. For example, $102 > 10^2$, but $102$ has $3$ digits, not $2$, so $\lceil \log_{10} 102 \rceil = 3$, and we divide by $10^3$ to get $0.102$. It works!

But try this out for say, $x = 100$, and $\lceil \log_{10} 100 \rceil = 2$, so we end up with $\frac{100}{100^2} = 1$. To fix this problem, we adjust the denominator $10^{\lfloor \log_{10} x \rfloor + 1}$, which has the same effect for all other numbers.

And there are other problems when $0 < x < 0.1$, as now $\log_{10} x ≤ -2$, so the denominator is less than $1$ and we end up multiplying by powers of $10$. However, the ceiling of these values of $x$ is always $1$, so the result is $0.1$.

There you have it: that's how we got the function above.