I really need to find the base of a logarithm when I know logarithm number $x$ and logarithm value which is exponent in exponentiation.

In five seconds or 175 tics the brightness level will drop from $\cos45^o$ to $0$ according logarithm function. Initial brightness is: $f=\log_b 175=\cos45^o$. I need to find $b$ - logarithm base. I think it is equal to: $b=\sqrt[\cos45^o]{175}\approx 1 486,397031$.

The problem is that I don't have custom root function. In my ACS script I need to write new function that would calculate any root (not only square root, not only cubic root). In other words I need such root calculation algorithm. Can you tell me how or provide such information?

I know that I can really do it using MS-Windows 10 calculator by using yroot function: Watch this
But I'm doing this for game. I need algorithm.
Also watch this: Angles Image

I'll do revision in my next answer.

  • $\begingroup$ Could you include a "tl;dr" part at the beginning that simply gives the equation (or a specific example of the type of equation) you want solved? To me what you've written seems like asking someone how to hit a nail with a hammer, and you're telling us that this is for something you're building in New Jersey at 4:00 PM with a slight rain and 17 people watching and $\ldots$ $\endgroup$ Oct 7, 2020 at 18:41
  • $\begingroup$ Alright. I reduced text amount. Concentrated to the problem. $\endgroup$
    – Tomasm21
    Oct 7, 2020 at 19:03
  • $\begingroup$ $$\log_b a=\frac{\ln a}{\ln b}$$and the logarithms on the right side need not have base $e$. $\endgroup$
    – user170231
    Oct 7, 2020 at 19:11
  • 1
    $\begingroup$ So, given $\log_b x = y,$ you want to solve for $b$ in terms of $x$ and $y$? Since this logarithmic equation is equivalent to $b^y = x,$ we get $b = \sqrt[y] x.$ Or, as @user170231 has noted, $\log_b x$ can be rewritten as $\frac{\ln x}{\ln b}$ (or as $\frac{\log_{10} x}{\log_{10} b}$ if you use base-$10$ logarithms). Thus, the equation becomes $\frac{\ln x}{\ln b} = y.$ Solving for $\ln b$ gives $\ln b = \frac{\ln x}{y},$ and now you can exponentiate (with base $e)$ both sides to get $b = e^{\frac{\ln x}{y}},$ or $b = {10}^{\frac{\log_{10} x}{y}}$ if you start with base-$10$ logarithms. $\endgroup$ Oct 7, 2020 at 19:27
  • 1
    $\begingroup$ You might be able to use an appropriate Taylor series approximation, although its validity will only be good for short intervals of the variable, and for longer intervals you might have to resort to some kind of piecewise defined function (i.e. defined by cases). This sounds like something someone here might be willing to look into, so perhaps you can revise your question a little by mentioning what I've said. However, you'll want to specify what range of values you want to do this for. $\endgroup$ Oct 7, 2020 at 19:59

2 Answers 2


So, given $\log_b x = y$, I want to solve for b in terms of $x$ and $y$. This logarithmic equation is equivalent to $b^y=x$, $b=\sqrt[y] x$. Logarithm can also be rewritten as:
$\log_b x = \frac{\log_{10}x}{\log_{10}b}=y$. Solving for $\log_{10}b$ gives $\log_{10}b=\frac{\log_{10}x}{y}$. Now I can exponentiate (with base 10) both sides to get $b=10^\frac{\log_{10}x}{y}$.
I got this thanks to Dave L. Ranfro in comments.

I have function to calculate logarithm with any base, but I cannot get logarithm base $b$ on my system because there is no function to exponentiate when the exponent is rational or irrational number. I have to calculate this otherwise. I need such algorithm. Can it be some sort of Taylor series approximation?
On my ACS scripting system I'm capable to calculate logarithm. So the equation $\frac{\log_{10}x}{y}$ will be calculated to some real number. Lets mark it $k$: $\frac{\log_{10}x}{y}=k$. And now my logarithm base $b$ becomes short, good looking equation which can be found by any calculator: $b = 10^k, k \in\Bbb R$. I cannot calculate it. Lets try Taylor series. Help me with this. I need to get a number with 6 digits after comma.
$f(k)=10^k, k \in\Bbb R $.
$$ \sum_{n=0}^\infty f^{(n)}(k_0)\frac{(k-k_0)^n}{n!} $$ $$ f(k)=f(a)+\frac{f'(a)}{1!}(k-a)+\frac{f''(a)}{2!}(k-a)^2+\frac{f'''(a)}{3!}(k-a)^3+\cdots. $$
Ok, lets take my example from top when $x=175, y=\frac{\sqrt{2}}{2}$
$k=\frac{\log_{10}175}{\frac{\sqrt{2}}{2}}\approx 3,1721348293710402712145339574314$, and:
$b=10^k\approx 1 486,3970316880181727541497029745$

I need to get this using Taylor series. But I'm not sure how to start.
Perhaps I need to choose such number $a$ that makes $f(a)$ easy to compute. Since my $k$ number is irrational (or maybe rational) and have some digits after comma, so I am going to take only integer part. In my case it will be $3$:
$a=3, f(a)=10^3=1000$.

$f(k)=10^k,\quad f'(k)=\ln 10\cdot 10^k,\quad f''(k)=(\ln 10\cdot 10^k)'=(\ln 10)^2\cdot 10^k, \\ f'''(k)=((\ln 10)^2\cdot 10^k)'= (\ln 10)^3\cdot 10^k.$

$f(k)=10^k\approx 10^3+\frac{\ln 10\cdot 10^3}{1!}(k-3)+\frac{(\ln 10)^2\cdot 10^3}{2!}(k-3)^2+\frac{(\ln 10)^3\cdot 10^3}{3!}(k-3)^3 \approx 1 485,2814946439140703778969615533$

Looks like I got something similar. But I'm still not sure whether I did it correctly. I need math professional approval. What do you think? Maybe.. Do I need fourth derivative to be this even more correct?


Do you really need log for this? I think some sort of simple fractional power might work as well.

Check out this graph on Desmos. (You can click on the sine-curve looking emblem next to each equation to show/hide them.) I think the cube root looks close enough for setting the brightness.

And it wouldn't be too hard to take one of the functions for Sqrt found here and repurpose them to find the cube root.

  • $\begingroup$ Nice graphs. And I see you are familiar with ACS and its wiki. But it my action coefficient is not necessarily 175. It depends on the distance. And it is time in tics for how long the blind effect lasts. So it won't be the same formula all the time. And FadeTo operates within (0.0, 1.0) range. It starts from full FadeTo(255, 255, 255, 0.999, 1.0); and falls down according logarithmic function. I choose logarithm because it tends to maintain the highest possible value over time. When the enemy is in front then logarithm base and logarithm number is the same. Value is then 1.0. And drops. $\endgroup$
    – Tomasm21
    Oct 8, 2020 at 20:50

You must log in to answer this question.

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