Search code examples
javascriptalgebra

Javascript - Find the base of an exponential equation


I was wondering if anyone knew how to find the base of an exponential equation in Javascript.

I couldn't find any function that allows this to be done (e.g. using the Math functions).

For example, how do I find 'b' in the following equation:

y = b^t

Thanks in advance for any help you can provide.


Solution

  • If you know what are the values of y and t are, you can get the value of b by calculating the t-th root of y like this:

    Math.pow(y, 1/t);
    

    Source: JavaScript: Calculate the nth root of a number